#2 First TypeScript program
Created a file index.ts
In terminal ; tsc.cmd index.ts to create a js file with the code in js of index.ts.
(In typeScript the name of the variable and constant should be proper like age, num and cannot be like a, x.)
In typeScript once the type of a variable is given, it cannot be modified in the next line.
Example:
let age:number=10;
age="hello";
(this is incorrect).
_____________________________________________________________________________________
We use tsc.cmd --init to create a TS config file.
Emit means to convert all the TS files to JS files. When a TS file is saved, the TS compiler emits an JS file corresponding to the JS code.
In config file, we modified some of the configurations.
=>Set rootDir to "./src" (Changes the root directory)
=>Set outDir to :./Dist" (Creates an output folder for all emitted files)
=>Set removeComments to "true" (Removes all the comments when emitting an JS file)
=> Set noEmitOnError to true (Disables emitting files to JS when there is an error is TS)
=> Set sourceMap to true (Creates source map files to emitted files)
Comments
Post a Comment