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.
Asked
Active
Viewed 9,467 times
21

millimoose
- 39,073
- 9
- 82
- 134
1 Answers
20
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.

Matt McCutchen
- 28,856
- 2
- 68
- 75
-
3TIL: Someone created a [compiler plugin](https://github.com/Microsoft/TypeScript/issues/28306#issuecomment-848699396). Seems to work so far (only tested the language server) – olejorgenb Jul 12 '21 at 13:17