allegro / typescript-strict-plugin

Typescript plugin that allows turning on strict mode in specific files or directories.
MIT License
332 stars 29 forks source link

`tsc-strict` doesn't work with `--watch` flag #79

Open jandreola opened 2 months ago

jandreola commented 2 months ago

Documentation mentions that all tsc flags are supported by tsc-strict. But when I try to run tsc-strict with --watch I get the command stuck on ⠏ Looking for strict files....

Running the command in non watch mode works correctly. And the IDE also show errors correctly.

Any ideas if that is some sort of limitation of tsc-strict command?

I'm using typescript-strict-plugin@2.4.4 and typescript@5.4.5

KostkaBrukowa commented 2 months ago

Yes, tsc-strict wasn't designed to work with --watch in mind and it wont work. It basically runs tsc twice, one time with strict flag and compares the outputs after tsc ends, and if you run with --watch flag the output will never be collected because tsc will never end

heyimalex commented 2 months ago

You could potentially create a PR to add this. There is an example of an incremental program watcher inside of the typescript docs, and you'd just filter out errors coming from strict files.

Here's what I rigged up, though it's not directly usable because it uses internal tools, maybe a good starting place. The strictify command is just generating a tsconfig.strict.json which is a copy of the base tsconfig.json but with strict enabled. There's definitely a way to handle that programatically.