Many beginners still facing the difficulties while doing Environment setup for Learn typescript. [before step-up to Angular]
Thanks.
So it's 8 simple steps to set an Environment to learn TypeScript with Visual Studio Code.
Installing the TypeScript compiler by:
npm install -g typescript
Create a file - tsconfig.json
- inside your folder(ex. LearnTSFolder)
and put this code inside - tsconfig.json
- file
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}
Now Create a simple TS file HelloWorld.ts
, and put this code inside this ts file:
class Startup {
public static main(): number {
console.log('Hello World, Wazz Up');
return 0;
}
}
Startup.main();
Now at Terminal run this command:
tsc HelloWorld.ts
............
so by this you can see new transpiled file - HelloWorld.js
generate inside the our folder
Now Execute Run Build Task (Ctrl+Shift+B) from the global Terminal menu
IT'S DONE NOW..: To execute code; just run below command at Terminal:
node HelloWorld.js
this way we can see below message in Terminal:
Hello World, Wazz Up