forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmappedTypeTupleConstraintAssignability.types
76 lines (56 loc) · 2.24 KB
/
mappedTypeTupleConstraintAssignability.types
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
=== tests/cases/compiler/mappedTypeTupleConstraintAssignability.ts ===
// https://github.com/microsoft/TypeScript/issues/53359#issuecomment-1475390594
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
>Writeable : Writeable<T>
type EnumValues = [string, ...string[]];
>EnumValues : [string, ...string[]]
type Values<T extends EnumValues> = { [k in T[number]]: k; };
>Values : Values<T>
declare class ZodEnum<T extends [string, ...string[]]> {
>ZodEnum : ZodEnum<T>
get enum(): Values<T>
>enum : Values<T>
}
declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T): ZodEnum<Writeable<T>>;
>createZodEnum : <U extends string, T extends readonly [U, ...U[]]>(values: T) => ZodEnum<Writeable<T>>
>values : T
// https://github.com/microsoft/TypeScript/issues/53359#issuecomment-1475390607
type Maybe<T> = T | null | undefined;
>Maybe : Maybe<T>
type AnyTuple = [unknown, ...unknown[]];
>AnyTuple : [unknown, ...unknown[]]
type AnyObject = { [k: string]: any };
>AnyObject : { [k: string]: any; }
>k : string
type Flags = "s" | "d" | "";
>Flags : "" | "s" | "d"
interface ISchema<T, C = any, F extends Flags = any, D = any> {
__flags: F;
>__flags : F
__context: C;
>__context : C
__outputType: T;
>__outputType : T
__default: D;
>__default : D
}
declare class TupleSchema<
>TupleSchema : TupleSchema<TType, TContext, TDefault, TFlags>
TType extends Maybe<AnyTuple> = AnyTuple | undefined,
TContext = AnyObject,
TDefault = undefined,
TFlags extends Flags = ""
> {
constructor(schemas: [ISchema<any>, ...ISchema<any>[]]);
>schemas : [ISchema<any, any, any, any>, ...ISchema<any, any, any, any>[]]
}
export function create<T extends AnyTuple>(schemas: {
>create : <T extends AnyTuple>(schemas: { [K in keyof T]: ISchema<T[K], any, any, any>; }) => TupleSchema<T | undefined, AnyObject, undefined, "">
>schemas : { [K in keyof T]: ISchema<T[K], any, any, any>; }
[K in keyof T]: ISchema<T[K]>;
}) {
return new TupleSchema<T | undefined>(schemas);
>new TupleSchema<T | undefined>(schemas) : TupleSchema<T | undefined, AnyObject, undefined, "">
>TupleSchema : typeof TupleSchema
>schemas : { [K in keyof T]: ISchema<T[K], any, any, any>; }
}