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 //@ts-strict-ignore option #17

Closed andrewnester closed 2 years ago

andrewnester commented 2 years ago

Use case

I have an existing Typescript code base which does not follow Typescript strict mode but I want to have all new added files to be automatically enforced to be in strict mode.

Problem

At the moment it's not possible to accomplish without either fixing all existing code base and enable strict: true in tsconfig.json or relying on good intentions of including @//ts-strict in every new Typescript file

Proposal

Having //@ts-strict-ignore option allows to accomplish this in a smarter way. First, I can have a configuration like this:

{
 "compilerOptions": {
   ...
   "strict": false
   "plugins": [
    {
     "name": "typescript-strict-plugin".
     "paths": ["./src"]
    }
   ]
 }
}

Then I can add //@ts-strict-ignore to all existing Typescript file in my codebase and can incrementally fix these files and remove the comment. And now, when new file is added, it will be automatically enforced to follow strict mode unless //@ts-strict-ignore is explicitly added.

I'm curious what do you think about the idea or have alternative ways to implement this?

KostkaBrukowa commented 2 years ago

Hey! We have this kind of idea in working progress. We also noticed that it is a bit weird to add those comments in every file, so we decided to add the ts-strict-ignore mode to our tool. Thanks for asking!