What does "use strict" add for TypeScript code?
I am using TypeScript 1.6 and for me it is not clear what does "use strict" statement add in TypeScript?
For TypeScript compile time it adds variable name checks as well. E.g. the following is okay
var implements = 123;
But the following errors :
"use strict";var implements = 123; // Error: implements is a reserved keyword in strict mode
Note : TypeScript also prevents other errors irrespective of strict mode declarations which is what is happening in your samples.
The "use strict"
statement affects the runtime, so if something that's invalid in strict mode has gotten past the TypeScript compiler, it will still throw an error at runtime.