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

The auto-update flag allows for regressions to sneak in #16

Closed
cwhenderson20 opened this issue Mar 16, 2023 · 5 comments · Fixed by #17
Closed

The auto-update flag allows for regressions to sneak in #16

cwhenderson20 opened this issue Mar 16, 2023 · 5 comments · Fixed by #17

Comments

@cwhenderson20
Copy link

First of all, thanks for this tool! I'm working on migrating a moderately large code-base to full strict mode, and it will be instrumental in making that happen. I'm trying to figure out the best workflow for when, exactly, to run the CLI with the auto-update flag enabled. I want to make sure that files whose errors have all been fixed are removed from the loose files list as soon as possible, but here's a scenario that I just ran into:

  1. Init the tool as per the instructions; receive a list of loosely-checked files and ignored errors
  2. Work on one of those offending files to fix the errors
  3. Run loose-ts-check --auto-update and see that the file in question is removed from the list 🎉
  4. Edit that file again to re-introduce a strict-based error
  5. Run loose-ts-check --auto-update again

Here, the CLI correctly reports the error, but the auto-update mechanism then adds that file to the list of loosely-types files, which means running the compiler again will not produce the same error. The CLI reports this status:

error Command failed with exit code 2.                            
577 errors detected
576 errors have been ignored
1 errors were not ignored
1 errors could be ignored, as their error codes are ignored
src/data/config.ts(22,13): error TS2532: Object is possibly 'undefined'.
Additional 0 files will be ignored - registry will be updated
Updating the list of loosely type-checked files...
The list of loosely type-checked files updated successfully

Maybe I'm thinking about it incorrectly, but I would have expected that auto-update was a one-way street, only allowing files to be removed rather than added. It seems like because that specific error code was previously ignored, it allowed the offending file back onto the loose list.

For me, the question remains: how can I programmatically update (i.e., shrink) the list of loosely-checked files while ensuring that the files not on that list don't secretly introduce regressions?

@Gelio
Copy link
Owner

Gelio commented Mar 27, 2023

Hey, thanks for considering using this tool and asking well-described questions!

You are right, it seems auto-update should only shrink the ignored files and error codes, not expand them. I suppose the init flag should be responsible for generating the lists based on the status quo.

The fix requires refactoring the reporting and updating logic. I will try to do it over the upcoming weekend.

Gelio added a commit that referenced this issue Apr 1, 2023
The `auto-update` flag will no longer cause new paths to be added to the
registry of ignored files. This prevents regressions from sneaking in,
when some file was already conforming to the stricter config and an
ignored error code started appearing in that file.

Fixes #16
Gelio added a commit that referenced this issue Apr 1, 2023
The `auto-update` flag will no longer cause new paths to be added to the
registry of ignored files. This prevents regressions from sneaking in,
when some file was already conforming to the stricter config and an
ignored error code started appearing in that file.

Fixes #16
@Gelio Gelio closed this as completed in #17 Apr 1, 2023
@Gelio
Copy link
Owner

Gelio commented Apr 1, 2023

I have just released v2.0.0 which changes the --auto-update behavior to avoid adding new files to the ignored files registry. Let me know if that works the way you expect

@cwhenderson20
Copy link
Author

Thank you! I'll update next week and let you know.

@cwhenderson20
Copy link
Author

Spent some time checking this out after updating and it works great. Thank you for the quick turnaround!

@Gelio
Copy link
Owner

Gelio commented Apr 19, 2023

Great, I'm glad it works well for you! Thanks for the compliment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants