-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtypescript.ts
More file actions
130 lines (119 loc) · 2.6 KB
/
typescript.ts
File metadata and controls
130 lines (119 loc) · 2.6 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* This file is generated and managed by tsync */
/**
* Internally tagged enums have a key-value pair
* that discrimate which variant it belongs to
*/
export type InternalTopping =
| InternalTopping__Pepperoni
| InternalTopping__ExtraCheese
| InternalTopping__Custom;
/**
* Tasty!
* Not vegetarian
*/
type InternalTopping__Pepperoni = {
type: "PEPPERONI";
};
/** For cheese lovers */
type InternalTopping__ExtraCheese = {
type: "EXTRA CHEESE";
KIND: string;
};
/**
* Custom toppings
* May expire soon
* Note: because this is a newtype variant, it should be included in the typescript
*/
type InternalTopping__Custom = {
type: "CUSTOM"} & CustomTopping
/**
* Adjacently tagged enums have a key-value pair
* that discrimate which variant it belongs to, and
* can support tuple variants
*/
export type AdjacentTopping =
| AdjacentTopping__Pepperoni
| AdjacentTopping__ExtraCheese
| AdjacentTopping__Custom
| AdjacentTopping__CustomTwo;
/**
* Tasty!
* Not vegetarian
*/
type AdjacentTopping__Pepperoni = {
type: "Pepperoni";
};
/** For cheese lovers */
type AdjacentTopping__ExtraCheese = {
type: "ExtraCheese";
kind: string;
};
/**
* Custom toppings
* May expire soon
*/
type AdjacentTopping__Custom = {
"type": "Custom";
"value": CustomTopping;
};
/**
* two custom toppings
* Note: this test case is specifically for specifying a tuple of types
*/
type AdjacentTopping__CustomTwo = {
"type": "CustomTwo";
"value": [ CustomTopping, CustomTopping ];
};
/**
* Externally tagged enums ascribe the value to a key
* that is the same as the variant name
*/
export type ExternalTopping =
/**
* Tasty!
* Not vegetarian
*/
| {
"Pepperoni": {
[key: PropertyKey]: never;
}
}
/** For cheese lovers */
| {
"ExtraCheese": {
kind: string;
}
}
/**
* Custom toppings
* May expire soon
* Note: this test case is specifically for specifying a single type in the tuple
*/
| { "Custom": CustomTopping }
/**
* two custom toppings
* Note: this test case is specifically for specifying a tuple of types
*/
| { "CustomTwo": [ CustomTopping, CustomTopping ] };
export interface CustomTopping {
name: string;
expires_in: Date;
}
export interface CustomToppingCamel {
name: string;
expiresIn: Date;
}
/**
* All Unit Enums go to union of constant strings
* even if have explicit numeric annotations
* There is no case renaming on default
*/
export type Animal =
| "Dog" | "Cat";
export type AnimalTwo =
| "dog_long_extra" | "cat";
export type Tagged =
| Tagged__Test;
type Tagged__Test = {
type: "Test";
};