allegro / typescript-strict-plugin

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

tsc-strict does not work with emitDeclarationOnly and build option. #25

Closed mathieutu closed 2 years ago

mathieutu commented 2 years ago

Hi,

Because tsc-strict ends up to run tsc --strict --noEmit ...process.argv.slice(2):

Maybe passing the process.argv before strict could be enough for the build option, but I don't know if the noEmit option is really required.

Also, for the record, I've a project with 13106 ts files, and tsc-strict is very longer than tsc (mainly because of the Looking for strict files step). Maybe a cache could be considered?

I'm ready to do the PR when we agree on what to do.

Thanks for your package!

mathieutu commented 2 years ago

Hum actually --strict seems to not work with build at all. Investigating on that. And for the emitDeclarationOnly, we can add --emitDeclarationOnly false

KostkaBrukowa commented 2 years ago

About putting ...process.argv.slice(2) first makes more sense and I think it would solve the issue with first command line argument. I believe that noEmit option makes the plugin run a bit faster (if noEmit is set to false in tsconfig), because we don't really need the file output and we only care about errors The idea about cache is really great and it would actually speed up the process of tsc-scrict by 50%. I found the --listFiles option for the tsc and we would actually need to run tsc once and the difference between tsc-strict and tsc would be negligible. I'll make a PR for it.

Thanks for investigating

KostkaBrukowa commented 2 years ago

Btw. 13000 ts files is hell a lot :D

KostkaBrukowa commented 2 years ago

And about the noEmit flag I'm wondering what to do. Initially I've added the noEmit flag, because some project use babel to compile their projects and they don't have noEmit flag in their tsconfig. Without this flag running tsconfig would generate bunch of js files unnecessarily (default is false). So we have three options:

  1. Remove noEmit resulting in scenario above
  2. Leave like it is now resulting in error with compilation with tsconfig provided by you
  3. Search tsconfig and find if emitDeclarationOnly is present and don't add noEmit when it is

I think option 3 would be the best in this case, but I'm worring that there would be more cases like that with different flags. What do you think?

mathieutu commented 2 years ago

Actually I think that we can leave the noEmit like this, and let devs add --emitDeclarationOnly false if they need. Also, I found out that the build option is not compatible with any config via console option (including strict), so no need to move anything.

Thanks for the cache thing!

13000 ts files

yep, and it's only the front 😅