true-myth
Version:
A library for safe functional programming in JavaScript, with first-class support for TypeScript
29 lines (27 loc) • 834 B
TypeScript
/**
Provide a type which is effectively a type-safe, non-interchangeable empty
object to use instead of `null` or `undefined`.
@module
*/
declare const Tag: unique symbol;
/**
* Create a unique, nominalish type.
* @internal
*/
declare class _Unit {
private readonly [Tag];
}
/**
The `Unit` type exists for the cases where you want a type-safe equivalent of
`undefined` or `null`. It's a concrete instance, which won't blow up on you,
and you can safely use it with e.g. `Result` without being concerned that
you'll accidentally introduce `null` or `undefined` back into your
application.
Equivalent to `()` or "unit" in many functional or functional-influenced
languages.
*/
export declare const Unit: Unit;
export interface Unit extends _Unit {
}
export default Unit;
//# sourceMappingURL=unit.d.ts.map