Our current tsconfig.json is:
We have one more compiler option which we have not covered before. It is noImplicitAny.
Considering our file: city-App.ts:
Since, we did not specify a type for cityArea variable. Hence, it has received a type of any - although we did not specify a datatype for it.
Now, in the file tsconfig.json - If I set the compilerOptions - noImplicitAny to true.
Due to this, now, if we run tsc. We should receive a compiler warning. But, in general it is better to leave it as false.
{
"compilerOptions": {
/* Basic Options */
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"noImplicitAny":false,
"sourceMap":true,
"noEmitOnError": true
},
"exclude":[
"node_modules"
]
}
We have one more compiler option which we have not covered before. It is noImplicitAny.
Considering our file: city-App.ts:
let myCity:string = "Hyderabad";
let cityElevation: number = 505;
// added below
let cityArea;
cityArea = "Not Available";
Since, we did not specify a type for cityArea variable. Hence, it has received a type of any - although we did not specify a datatype for it.
Now, in the file tsconfig.json - If I set the compilerOptions - noImplicitAny to true.
"noImplicitAny":true,
Due to this, now, if we run tsc. We should receive a compiler warning. But, in general it is better to leave it as false.
No comments:
Post a Comment