UNPKG

857 BTypeScriptView Raw
1import { ISimpleType, Primitives } from "../../internal";
2/**
3 * `types.literal` - The literal type will return a type that will match only the exact given type.
4 * The given value must be a primitive, in order to be serialized to a snapshot correctly.
5 * You can use literal to match exact strings for example the exact male or female string.
6 *
7 * Example:
8 * ```ts
9 * const Person = types.model({
10 * name: types.string,
11 * gender: types.union(types.literal('male'), types.literal('female'))
12 * })
13 * ```
14 *
15 * @param value The value to use in the strict equal check
16 * @returns
17 */
18export declare function literal<S extends Primitives>(value: S): ISimpleType<S>;
19/**
20 * Returns if a given value represents a literal type.
21 *
22 * @param type
23 * @returns
24 */
25export declare function isLiteralType<IT extends ISimpleType<any>>(type: IT): type is IT;