Is it possible to enable strict checks done by the TSC compiler (i.e. --strict
et al.) file-by-file, say using a special comment? I'm working on an established Angular codebase that mostly doesn't take advantage of TS, and I'd like to have at least my own code be neater without also having to fix everybody else's code by turning the flag on for the whole project.
You can either set the --strict flag on the command line or specify the strict option within your project's tsconfig. json file to opt into this mode. As of TypeScript 4.3 in August 2021, the --strict flag enables the following eight compiler options: --alwaysStrict.
Because TypeScript was developed primarily as superset of JavaScript, by default it allows us to write code that is not super strict in types and other aspects.
You can do that by compiling with the --noImplicitUseStrict compiler option—add "noImplicitUseStrict": true to "compilerOptions" in tsconfig. json. Doing so will prevent the compiler from emitting "use strict" .
Not currently. See this open suggestion; I don't expect the TypeScript team to get around to it any time soon. One workaround might be to write a script that runs tsc
with the stricter checks enabled and filters the output for the files you want; see this answer for some prior art.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With