forked from Wulf/tsync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
typescript.ts
62 lines (57 loc) · 1.25 KB
/
typescript.ts
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
/* This file is generated and managed by tsync */
/**
* Variants should to discriminated unions
* The last serde/attribute combo matching the tag should be taken
*/
export type Message =
/** Per Enum case Docs One */
| {
last_precedent: "UnitCaseLeft",
}
/** Per Enum case Docs Two */
| {
last_precedent: "RequestLongTake",
id: string
method: string
params: number
}
| {
last_precedent: "Response",
id: string
result: Date
};
/** The default enum conversion uses external tagging */
export type ExternalMessage =
/** Per Enum case Docs One */
| {
"UnitCaseLeft": {}
}
/** Per Enum case Docs Two */
| {
"RequestLongTake": {
id: string
method: string
params: number
}
}
| {
"Response": {
id: string
result: 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";
/** Integer enums should follow rust discrimination if literals (doesn't evaluate expression) */
export enum Foo {
Bar = 0,
Baz = 123,
Quux = 124,
}