![]() ![]() If you want to specify the name of the output file: TSC will compile the code into JavaScript and output it in a file called index.js: var sport = 'football' We can now compile this down into JavaScript with the following command: tsc index Write some JavaScript or TypeScript: let sport = 'football' Open up your text editor and create a TypeScript file (for example, index.ts). To check if the installation is successful (it will return the version number if successful): tsc -v Then install the TypeScript compiler globally on your machine by running the following command: npm i -g typescript How to Set Up a TypeScript Project Install Node and the TypeScript Compilerįirst, ensure you have Node installed globally on your machine. It's a great tool to have in your arsenal. TypeScript has to be compiled – which can take time, especially in larger projects.īut the extra time that you have to spend writing more precise code and compiling will be more than saved by how many fewer bugs you'll have in your code.įor many projects – especially medium to large projects – TypeScript will save you lots of time and headaches.Īnd if you already know JavaScript, TypeScript won't be too hard to learn.TypeScript takes longer to write than JavaScript, as you have to specify types, so for smaller solo projects it might not be worth using it.Here's a short article I wrote demonstrating how TypeScript can prevent irritating bugs. Learning TypeScript will give you a better understanding, and a new perspective, on JavaScript.It's popular – knowing TypeScript will enable you to apply to more good jobs.And when working in a team, it is easier to see what the other developers intended to. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |