ts-opaque
Version:
Easy-to-use library that implements opaque types in TypeScript!
22 lines (21 loc) • 800 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = void 0;
/**
* `create` is a generic helper function that takes an opaque type `OpaqueType`
* as its sole type parameter as well as a value `value` whose type is
* assignable to the given opaque type's base type; `create` returns the given
* value casted to the opaque type.
*
* Likewise, to widen a value whose type is opaque, use `widen`.
*
* *Note:* At runtime, the given value is not modified in any way. What
* `create` returns is literally the same value as `value`.
*
* @template OpaqueType The opaque type to cast the given value `value` to.
* @param valueThe value that is to be casted to the given opaque type.
*/
function create(value) {
return value;
}
exports.create = create;
;