TypeScript
ts/no-ts-ignore
Silence a type error with @ts-expect-error and a reason, never @ts-ignore or @ts-nocheck.
minorstaticfe-typescript
Why
@ts-ignore hides every error on the next line, including the new ones a later change introduces, and stays forever after the original problem is fixed. @ts-nocheck does the same for a whole file. Nobody knows why it is there or whether it is still needed.
Fix
Fix the type. When that is not possible today, use // @ts-expect-error <why, and when it can go>: it hides the error and itself fails as soon as the error disappears, so it is removed on time.
Examples
// bad
// @ts-ignore
chart.render(data)
// good
// @ts-expect-error chart.js 4 types lack the plugin option; remove after upgrading to 5
chart.render(data, { plugins })Sources
Facts
- Id
ts/no-ts-ignore- Severity
- minor
- Check
- static checked in the source by
audit - Applies to
jsxvuesvelteastro- Only in projects with
typescript- Taught by the skill
fe-typescriptTypeScript- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain ts/no-ts-ignore