Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v2.0) Strict mode by default #19

Merged
merged 31 commits into from
Jan 24, 2022
Merged

(v2.0) Strict mode by default #19

merged 31 commits into from
Jan 24, 2022

Conversation

kamkry
Copy link
Collaborator

@kamkry kamkry commented Jan 16, 2022

We noticed that adding strict mode manually was not enough for project migration due to simply forgetting to add it in new files or in changed ones. The new version will enable strict mode by default (no need for ts-strict comment) and ignore it in a specific file one can add //@ts-strict-ignore at the top of a file. With that design new files automatically come with strict mode enabled and it's easier to notice ignored files when modifying them, encouraging to try to fix those errors.

What about migration?
The 2.0 version will come with a CLI tool that will automatically detect files with strict errors and add ignore comments to them. It will also remove unnecessary strict comments existing in the project.

The PR also introduces a major refactor, unifying the strict file detection between CLI tools and the TS plugin.

Tasks left

) =>
allFilePaths.filter(
(filePath) =>
!isFileStrictByPath(filePath, configPaths) && !filePathsWithErrors.includes(filePath),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that if we would convert filePathsWithErrors to set before filtering it could be a littlebit faster, but i dont know if its worth optimizing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set doesn't have a filter method unfortunately

Copy link
Collaborator

@KostkaBrukowa KostkaBrukowa Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was talking about something like this

export const getFilePathsWithoutErrors = (
  allFilePaths: string[],
  filePathsWithErrors: string[],
  configPaths?: string[],
) => {
  const filePathsWithErrorsSet = new Set(filePathsWithErrors);
  return allFilePaths.filter(
    (filePath) =>
      !isFileStrictByPath(filePath, configPaths) && !filePathsWithErrorsSet.has(filePath),
  );
}

Copy link
Collaborator

@KostkaBrukowa KostkaBrukowa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice PR. Good job!!

@aleksandrlat
Copy link

Hello @kamkry and @KostkaBrukowa!
Thank you for plugin!
Any idea when this will be merged and released?

@kamkry kamkry merged commit 8ed4e01 into master Jan 24, 2022
@kamkry kamkry deleted the feature/ts-strict-ignore branch January 24, 2022 07:38
@kamkry
Copy link
Collaborator Author

kamkry commented Jan 24, 2022

Hi @aleksandrlat, we've just published it with version 2.0.0-beta.0 🎉 It's published as beta because we want to make sure everything works poperly with that big change.

@aleksandrlat
Copy link

Awesome! Thank you @kamkry!

@kamkry kamkry linked an issue Jan 26, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants