October 2017
Intermediate to advanced
280 pages
6h 50m
English
Now, let's compile our first TypeScript program! Create a file called hello-world.ts and enter the following content:
// ch4/hello-world/hello-world.ts
console.log('Hello world!');
Since we've already installed the TypeScript compiler, we should have a global executable command called tsc. You can use it in order to compile the file:
$ tsc hello-world.ts
Now, you should see the hello-world.js file in the same directory where hello-world.ts is. The hello-world.js file is the output of the TypeScript compiler; it contains the JavaScript equivalent to the TypeScript we wrote. We can run this file using the following command:
$ node hello-world.js
Now, you'll see the Hello world! string printed on the screen. ...
Read now
Unlock full access