ts-guards
Version:
A collection of basic type guards.
17 lines • 511 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLiteralType = exports.isLiteral = void 0;
/**
* Literal Type
* Pass value or set as const for correct type inference
* See also https://www.typescriptlang.org/docs/handbook/literal-types.html
*/
function isLiteral(x, value) {
return x === value;
}
exports.isLiteral = isLiteral;
function isLiteralType(x, set) {
return set.has(x);
}
exports.isLiteralType = isLiteralType;
//# sourceMappingURL=literal-type.js.map