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

Add --project and -p command line option #11

Closed codeBelt closed 2 years ago

codeBelt commented 2 years ago

Currently we use "strict": true but have "strictNullChecks": false. When we run yarn tsc-strict we get 🎉 All files passed.

{
 "compilerOptions": {
   ...
   "strict": true,
   "strictNullChecks": false,
   "plugins": [
    {
     "name": "typescript-strict-plugin"
    }
   ]
 }
}

I am not sure how the plugin should work but I thought it would ignore the strictNullChecks and make it true.

I would like to keep the tsconfig.json as is and not remove "strictNullChecks": false so it can work with our current workflow. Can you allow tsc-strict to take the --project and -p command line options so we can point to another file (tsc-strict -p tsconfig-strict.json)?

codeBelt commented 2 years ago

I ended up renaming tsconfig.json to tsconfig-base.json and made tsconfig.json look like:

{
  "extends": "./tsconfig-base.json",
  "compilerOptions": {
    "strictNullChecks": true,
    "plugins": [
      {
        "name": "typescript-strict-plugin",
        "paths": ["./src/stores/", "./src/utils/"]
      }
    ]
  }
}

I think this works better because now my IDE displays the stricter warnings/errors but our build process can use the less strict version.

Maybe there should be a way to tell tsc-strict to override strictNullChecks or one of the other option(s) that is combined under the strict option? Then I wouldn't have to do the tsconfig extend thing.

codeBelt commented 2 years ago

I guess my team is not liking all the strict null warnings in the IDE. Maybe allowing tsc-strict to accept the --project and -p command line options is not a bad idea. Then I can slowly clean up the null warnings without the team seeing them.

KostkaBrukowa commented 2 years ago

To be honest we could actually pass all the arguments that typescript supports to the tsc not only --project. Right now we only pass --strict --noEmit but adding support to pass --project and the rest would be nice feature. I'll try to add this over the weekend. Thanks for the idea