TypeScript

ts/no-ts-ignore

Silence a type error with @ts-expect-error and a reason, never @ts-ignore or @ts-nocheck.

drobnastatycznefe-typescript

Dlaczego

@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.

Poprawka

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.

Przykłady

// 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 })

Źródła

Fakty

Identyfikator
ts/no-ts-ignore
Waga
drobna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
jsx vue svelte astro
Tylko w projektach z
typescript
Uczy jej skill
fe-typescript TypeScript
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain ts/no-ts-ignore