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) • 391 B
TypeScript
import { type Nullable, type NotNull } from '../core/nullable.js';
/**
* Return _input_ as `T` if the passed _input_ is not `null`.
* Otherwise, return _defaultValue_.
*
* * _defaultValue_ must not be `Nullable<*>`.
* * If the _defaultValue_ is `null`, throw `TypeError`.
*/
export declare function unwrapOrForNullable<T>(input: Nullable<T>, defaultValue: NotNull<T>): NotNull<T>;