TypeScript

ts/strict

TypeScript runs with strict on; no config turns strict or one of its checks (strictNullChecks, noImplicitAny...) off.

umiarkowanastatycznefe-typescript

Dlaczego

Without strictNullChecks, every value may silently be null or undefined and the compiler never says so; without noImplicitAny, untyped parameters turn checking off where it matters most. Most "Cannot read properties of undefined" errors in production are what strict mode reports at build time.

Poprawka

Remove "strict": false and any strict flag set to false. TypeScript 6.0 and later turn strict on by default; on 5.x write "strict": true. In a large old codebase, turn it on and silence the existing errors file by file with // @ts-expect-error and a reason, so new code is strict from today.

Przykłady

// bad
{ "compilerOptions": { "strict": false } }
{ "compilerOptions": { "strict": true, "strictNullChecks": false } }
// good
{ "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true } }

Źródła

Fakty

Identyfikator
ts/strict
Waga
umiarkowana
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
project
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/strict