On this page
NonNullable
Prev: `Extract` | Up: union_and_nullability | Next: function_and_promise
Rel: union_and_nullability, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #union_and_nullability #tier/core
Syntax & Overview
NonNullable<T>
Removes null and undefined from T.
Notes & Pitfalls
- Strips
nullandundefinedfrom a type: Works cleanly in generic helpers whereTmight be nullable.
Example
type RawId = string | null | undefined;
type CleanId = NonNullable<RawId>; // string
Linked from
Related notes
- tuts/typescript/utility_types/union_and_nullability/Extract Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/union_and_nullability Linked here; links to this page; shared tags: #typescript, #web
- tuts/typescript/type_system/conditional_and_mapped_types Linked here; shared tags: #typescript, #web
- tuts/typescript/utility_types/function_and_promise Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/any shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/enum shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #tier, #typescript, #web