I use Visual Studio code to design the example in this article. Of course you can use any other editor as well. My application is also based on NodeJS, which you can download from the project's website or via the package manager of your choice.
Let's start with an example. How could it be otherwise, we will develop our Hello World application in TypeScript. Next snippet is all we need:
var msg:string = "Hello World!"; console.log(msg);
If everything is ok, a new file will be created with the same name as our .ts file. Now, however, with the.js extension. The new file contains the following content:
var msg = "Hello World!"; console.log(msg);
This creates the "Hello World!" output we are looking for.
The TypeScript compiler also helps you to avoid errors. For example, if you try to assign a text to a variable of type number, you will receive the following error message when compiling:
main.ts(3,5): error TS2322: Type '"test"' is not assignable to type 'number'.
Depending on which editor or plugins you are using, you will be notified during development. VS code, for example, shows you directly the displays the corresponding error message.
Of course, this is only the tip of the iceberg, but we want to start small.
If you would like to learn more about TypeScript, the language has extensive documentation. I have also planned a follow-up article for the next steps.