21

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.

millimoose
  • 39,073
  • 9
  • 82
  • 134

1 Answers1

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
  • 3
    TIL: 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