undefined
The JavaScript value meaning not set: a variable with no value yet, a missing property or a function that returned nothing.
In more detail
Reading a property that does not exist gives undefined rather than an error. With strictNullChecks, TypeScript treats undefined as its own type that must be handled explicitly.
Example
In a patch payload, an omitted or undefined bio means leave the field unchanged, while bio: null means clear itRelated terms
- null — A special value meaning no value or no object, set on purpose to show that something is empty or absent.
- optional property — An object property marked with a question mark, such as bio?: string, which may be left out.
- strictNullChecks — The compiler option that makes null and undefined separate types, so you must handle them before using a value.
- exactOptionalPropertyTypes — The compiler option that forbids setting an optional property to undefined explicitly, so it must be omitted or given a real value.
Taught in
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript
- any Versus unknown: Defensive Typing In Practice — Production TypeScript
- void, undefined And null: Exact Optional Property Types — Production TypeScript
- Optional Properties, Readonly And Index Signatures — Production TypeScript
- Discriminated Unions: Tagged Variants And Pattern Matching — Production TypeScript
- Typeof Guards, Truthiness And Equality Narrowing — Production TypeScript
- Custom Type Predicates: Functions Returning is Type — Production TypeScript
- Assertion Signatures: asserts condition And Invariants — Production TypeScript
- Why Generics: Functions, Identities And Type Variables — Production TypeScript
- Generic Interfaces, Classes And Type Aliases — Production TypeScript
- Generic Constraints: extends, keyof And Indexed Access — Production TypeScript
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript
- The Spine Artifact: Generating Typed Models From OpenAPI — Production TypeScript