Type aliases
UnwrappedOption
UnwrappedOption<
T
,U
> =T
extendsSome
<infer TValue> ?UnwrappedOption
<TValue
,U
> :T
extendsNone
?U
:T
extendsUnUnwrappables
?T
:T
extendsobject
?{ [key in keyof T]: UnwrappedOption<T[key], U> }
:T
extends infer TItem[] ?UnwrappedOption
<TItem
,U
>[] :T
A type that recursively unwraps nested Option types.
This type resolves all nested Option values, ensuring that deeply wrapped values are properly extracted.
- If
T
is an Option, it resolves to the contained value. - If
T
is a known primitive or immutable type, it remains unchanged. - If
T
is an object or array, it recursively unwraps any options found.
The fallback type U
(default: null
) is used in place of None
values.
Type Parameters
Type Parameter | Default type | Description |
---|---|---|
T | - | The type to be unwrapped. |
U | null | The fallback type for None values (defaults to null ). |
Examples
Resolving nested Option
types.
Resolving options inside objects and arrays.