soundness
The guarantee that a program which passes type checking can never hold a value of the wrong type at run time.
In more detail
TypeScript is deliberately not fully sound: features such as any, type assertions and unchecked array indexes let wrong values slip through. The design trades some safety for convenience with existing JavaScript. Strict compiler options and avoiding any narrow the gap.
Related terms
- any (type) — The TypeScript type that switches off type checking for a value, so anything can be done with it without errors.
- type assertion (TypeScript) — Writing value as Type to tell the compiler to treat a value as a type, without any check that it really is.
- strict (compiler option) — The strict compiler option, which turns on a family of stronger checks such as strictNullChecks and noImplicitAny in one setting.
- noUncheckedIndexedAccess — The compiler option that adds undefined to the type of every array index or dictionary lookup, because the entry might not exist.
Taught in
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript