/
languageServerFeatures.source.ts
76 lines (51 loc) · 1.25 KB
/
languageServerFeatures.source.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import * as z from "../index";
export const filePath = __filename;
// z.object()
export const Test = z.object({
f1: z.number(),
});
export type Test = z.infer<typeof Test>;
export const instanceOfTest: Test = {
f1: 1,
};
// z.object().merge()
export const TestMerge = z
.object({
f2: z.string().optional(),
})
.merge(Test);
export type TestMerge = z.infer<typeof TestMerge>;
export const instanceOfTestMerge: TestMerge = {
f1: 1,
f2: "string",
};
// z.union()
export const TestUnion = z.union([
z.object({
f2: z.string().optional(),
}),
Test,
]);
export type TestUnion = z.infer<typeof TestUnion>;
export const instanceOfTestUnion: TestUnion = {
f1: 1,
f2: "string",
};
// z.object().partial()
export const TestPartial = Test.partial();
export type TestPartial = z.infer<typeof TestPartial>;
export const instanceOfTestPartial: TestPartial = {
f1: 1,
};
// z.object().pick()
export const TestPick = TestMerge.pick({ f1: true });
export type TestPick = z.infer<typeof TestPick>;
export const instanceOfTestPick: TestPick = {
f1: 1,
};
// z.object().omit()
export const TestOmit = TestMerge.omit({ f2: true });
export type TestOmit = z.infer<typeof TestOmit>;
export const instanceOfTestOmit: TestOmit = {
f1: 1,
};