Issue
Many beginners still facing the difficulties while doing Environment setup for Learn typescript. [before step-up to Angular]
Thanks.
Solution
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- Install Visual Studio Code
- Create new folder or open existing folder (empty Ex.LearnTSFolder) in - Visual Studio Code
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.jsgenerate inside the our folderNow 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.jsthis way we can see below message in Terminal:
Hello World, Wazz Up
Answered By - ThermeshB
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.