-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
@ts-expect-error and @ts-ignore overly broad in supressing errors #47551
Comments
On second viewing, this isn't a duplicate. |
In this very specific case, we could turn off the rule that says we shouldn't report missing property errors when a type error between a declared and provided property don't match. But there's not really much we can do in the general case -- once your program has a type error in it, it's up to our heuristics to decide exactly what the most useful reporting of that type error is. It might be in one place, it might be in four places, it might be in ten. The feature design of |
@MLoughry I figured out how to use the TypeScript AST to detect problem spots where https://gist.github.com/dbalatero/82bb17596fe4e8b7d1c5d56d8f6018fb If you want to try it on your codebase, you can try dropping it in and wrapping it in a little script like I show in the README. |
Bug Report
We migrated our codebase with >1.5M lines of TS code to use strict mode everywhere, resulting in >30k new errors caught by strict mode. To ease the migration, we annotated each error with
// @ts-expect-error
and additional comments pointing to a wiki about the migration. However, we're finding the disable comment to be overly-broad, suppressing new errors that are unrelated to the line in question or strict mode. In particular, adding a new property to a type doesn't flag instances where we have a@ts-expect-error
suppressing astrictNullChecks
error.🔎 Search Terms
ignore, expect, error, @ts-ignore, @ts-expect-error
🕗 Version & Regression Information
@ts-ignore
and@ts-expect-error
⏯ Playground Link
https://www.typescriptlang.org/play?ts=4.5.4#code/JYOwLgpgTgZghgYwgAgGIHt3IN4ChnJwBcyIArgLYBG0A3PslSQM5hSgDm9AvrrgPT9kAUQAeABwgJIAE2TQo6KMhlkUYLAAMyIGRBigIMzcnGLJUMAE9kmuJoA0AoVTJhkzMuLMRmzX-JQisqq6lgUwH6cpubQ1rZUmrgI6CCsjHBQJBhYALw4DILIAAJgzAC0EBJSYJVBSgzEyDp6BiBGuLzOyADC6BTiwAA20MgpQTVDNgpKzMipyGAAFig0Q+gA7shDhsgAFJopae5UcABe2ZjI+diaAJTdoYtYyygRUSAcMegW8ZqJyVS6VOFzQVxujRIAEZOkA
Playground link with relevant code
💻 Code
🙁 Actual behavior
Compiler suppresses error about missing property.
🙂 Expected behavior
Compiler raises error about missing property that is not on the line covered by
@ts-expect-error
The text was updated successfully, but these errors were encountered: