NonNullable<T>
The utility type that removes null and undefined from type T.
In more detail
NonNullable<string | null | undefined> is string. The course uses it in an assertion function that proves a value is present.
Related terms
- null — A special value meaning no value or no object, set on purpose to show that something is empty or absent.
- undefined — The JavaScript value meaning not set: a variable with no value yet, a missing property or a function that returned nothing.
- assertion function — A function whose return type is asserts condition or asserts val is Type, which throws if the check fails and otherwise narrows the caller's code.
Taught in
- Assertion Signatures: asserts condition And Invariants — Production TypeScript
- Core Utilities: Partial, Required, Readonly, Pick And Omit — Production TypeScript
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript