TypeScript Types
undefined — missing or undefined value
With strictNullChecks enabled, undefined is distinct from null and ordinary values. Optional parameters and reads of optional properties may produce undefined. A default parameter or explicit check can handle the missing case. An absent property and a present property whose value is undefined are not always equivalent, especially with exactOptionalPropertyTypes enabled. Example output: "default". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.
Formal Syntax & Structure
typescript syntaxtypescript
let value: undefined;Working Example
Example Snippettypescript
function label(value?: string): string { return value ?? "default";}console.log(label());