option-t
Version:
A toolkit of Nullable/Option/Result type implementation in ECMAScript. Their APIs are inspired by Rust's `Option<T>` and `Result<T, E>`.
10 lines (9 loc) • 441 B
TypeScript
import { type NotUndefined, type Undefinable } from '../core/undefinable.js';
/**
* Return _input_ as `T` if the passed _input_ is not `undefined`.
* Otherwise, return _defaultValue_.
*
* * _defaultValue_ must not be `Undefinable<*>`.
* * If the result of _defaultValue_ is `undefined`, throw `TypeError`.
*/
export declare function unwrapOrForUndefinable<T>(input: Undefinable<T>, defaultValue: NotUndefined<T>): NotUndefined<T>;