API reference / @evolu/common / Type / literal
Function: literal()
function literal<T>(expected): LiteralType<T>;
Defined in: packages/common/src/Type.ts:2130
Literal Type.
https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types
Example
const LiteralHello = literal("Hello");
const result = LiteralHello.from("Hello"); // ok("Hello")
const errorResult = LiteralHello.from("World"); // err
TODO: Add JsonValue
Type Parameters
| Type Parameter |
|---|
T extends Literal |
Parameters
| Parameter | Type |
|---|---|
expected | T |
Returns
LiteralType<T>