AZ.dev

TypeScript

Type system, compiler options, and type-level programming

How-To Guides

Check an object against a type without losing its literal types
Use satisfies when you want the compiler to check a value against a type but keep the narrower type it inferred.
satisfiesinferenceliteral-typesconst
Make array and record lookups admit they can be undefined
Turn on noUncheckedIndexedAccess so indexing an array or a string-keyed record types as T | undefined, which is what it is at runtime.
tsconfigstrictnoUncheckedIndexedAccessundefinedarrays
Make a switch fail to compile when a union case is missing
Assign the narrowed value to never in the default branch.
neverexhaustiveunionswitchnarrowing
typescript-eslint --fix can break Prisma JSON column writes
@typescript-eslint/no-unnecessary-type-assertion (tightened in 8.59) flags as unknown as object casts at Prisma JSON write sites as "unnecessary." They aren't.
eslinttypescript-eslintprismatype-assertionlint-fix