Type alias Maybe<Value>

Maybe<Value>: Value | undefined

Value that can be undefined.

Remarks

Union type useful for cases where a value might be undefined, and provides a simple way to express this in TypeScript. For example, the return type of a function that returns a string or undefined could be typed as Maybe<string>.

Example

type MaybeNumber = Maybe<number>;
const maybeNumber: MaybeNumber = 1;
const notNumber: MaybeNumber = undefined;

Type Parameters

  • Value

    The type of the value to make optional.