UNPKG

549 BTypeScriptView Raw
1import { Key } from './Key';
2declare const id: unique symbol;
3/**
4 * Create your own opaque sub-type from a type `A`
5 * @param A to be personalized
6 * @param Id to name the sub-type
7 * @returns A new type `Type<A, Id>`
8 * @example
9 * ```ts
10 * import {A} from 'ts-toolbelt'
11 *
12 * type EUR = A.Type<number, 'eur'>
13 * type USD = A.Type<number, 'usd'>
14 *
15 * let eurWallet = 10 as EUR
16 * let usdWallet = 15 as USD
17 *
18 * eurWallet = usdWallet // error
19 * ```
20 */
21export declare type Type<A extends any, Id extends Key> = {
22 [id]: Id;
23} & A;
24export {};