Skip to content

Commit 49ab144

Browse files
authored
Merge pull request #47 from lambdalisue/readonly
💥 Improve tuple type handlings
2 parents 10b9440 + b14912b commit 49ab144

File tree

4 files changed

+722
-83
lines changed

4 files changed

+722
-83
lines changed

__snapshots__/is_test.ts.snap

Lines changed: 105 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
export const snapshot = {};
22

3-
snapshot[`isArrayOf<T> > returns properly named function 1`] = `"isArrayOf(isNumber)"`;
3+
snapshot[`isLiteralOf<T> > returns properly named function 1`] = `'isLiteralOf("hello")'`;
44
5-
snapshot[`isArrayOf<T> > returns properly named function 2`] = `"isArrayOf((anonymous))"`;
5+
snapshot[`isLiteralOf<T> > returns properly named function 2`] = `"isLiteralOf(100)"`;
6+
7+
snapshot[`isLiteralOf<T> > returns properly named function 3`] = `"isLiteralOf(100n)"`;
8+
9+
snapshot[`isLiteralOf<T> > returns properly named function 4`] = `"isLiteralOf(true)"`;
10+
11+
snapshot[`isLiteralOf<T> > returns properly named function 5`] = `"isLiteralOf(null)"`;
12+
13+
snapshot[`isLiteralOf<T> > returns properly named function 6`] = `"isLiteralOf(undefined)"`;
14+
15+
snapshot[`isLiteralOf<T> > returns properly named function 7`] = `"isLiteralOf(Symbol(asdf))"`;
16+
17+
snapshot[`isObjectOf<T> > returns properly named function 1`] = `
18+
"isObjectOf({
19+
a: isNumber,
20+
b: isString,
21+
c: isBoolean
22+
})"
23+
`;
24+
25+
snapshot[`isObjectOf<T> > returns properly named function 2`] = `"isObjectOf({a: a})"`;
26+
27+
snapshot[`isObjectOf<T> > returns properly named function 3`] = `
28+
"isObjectOf({
29+
a: isObjectOf({
30+
b: isObjectOf({c: isBoolean})
31+
})
32+
})"
33+
`;
634
735
snapshot[`isTupleOf<T> > returns properly named function 1`] = `
836
"isTupleOf([
@@ -26,67 +54,111 @@ snapshot[`isTupleOf<T> > returns properly named function 3`] = `
2654
])"
2755
`;
2856
57+
snapshot[`isOptionalOf<T> > returns properly named function 1`] = `"isOptionalOf(isNumber)"`;
58+
2959
snapshot[`isUniformTupleOf<T> > returns properly named function 1`] = `"isUniformTupleOf(3, isAny)"`;
3060
3161
snapshot[`isUniformTupleOf<T> > returns properly named function 2`] = `"isUniformTupleOf(3, isNumber)"`;
3262
3363
snapshot[`isUniformTupleOf<T> > returns properly named function 3`] = `"isUniformTupleOf(3, (anonymous))"`;
3464
65+
snapshot[`isInstanceOf<T> > returns properly named function 1`] = `"isInstanceOf(Date)"`;
66+
67+
snapshot[`isInstanceOf<T> > returns properly named function 2`] = `"isInstanceOf((anonymous))"`;
68+
69+
snapshot[`isAllOf<T> > returns properly named function 1`] = `
70+
"isAllOf([
71+
isObjectOf({a: isNumber}),
72+
isObjectOf({b: isString})
73+
])"
74+
`;
75+
3576
snapshot[`isRecordOf<T> > returns properly named function 1`] = `"isRecordOf(isNumber)"`;
3677
3778
snapshot[`isRecordOf<T> > returns properly named function 2`] = `"isRecordOf((anonymous))"`;
3879
39-
snapshot[`isObjectOf<T> > returns properly named function 1`] = `
40-
"isObjectOf({
41-
a: isNumber,
42-
b: isString,
43-
c: isBoolean
44-
})"
80+
snapshot[`isOneOf<T> > returns properly named function 1`] = `
81+
"isOneOf([
82+
isNumber,
83+
isString,
84+
isBoolean
85+
])"
4586
`;
4687
47-
snapshot[`isObjectOf<T> > returns properly named function 2`] = `"isObjectOf({a: a})"`;
88+
snapshot[`isLiteralOneOf<T> > returns properly named function 1`] = `'isLiteralOneOf(["hello", "world"])'`;
4889
49-
snapshot[`isObjectOf<T> > returns properly named function 3`] = `
50-
"isObjectOf({
51-
a: isObjectOf({
52-
b: isObjectOf({c: isBoolean})
53-
})
54-
})"
90+
snapshot[`isTupleOf<T, E> > returns properly named function 1`] = `
91+
"isTupleOf([
92+
isNumber,
93+
isString,
94+
isBoolean
95+
], isArray)"
5596
`;
5697
57-
snapshot[`isInstanceOf<T> > returns properly named function 1`] = `"isInstanceOf(Date)"`;
98+
snapshot[`isTupleOf<T, E> > returns properly named function 2`] = `"isTupleOf([(anonymous)], isArrayOf(isString))"`;
5899
59-
snapshot[`isInstanceOf<T> > returns properly named function 2`] = `"isInstanceOf((anonymous))"`;
100+
snapshot[`isTupleOf<T, E> > returns properly named function 3`] = `
101+
"isTupleOf([
102+
isTupleOf([
103+
isTupleOf([
104+
isNumber,
105+
isString,
106+
isBoolean
107+
], isArray)
108+
], isArray)
109+
])"
110+
`;
60111
61-
snapshot[`isLiteralOf<T> > returns properly named function 1`] = `'isLiteralOf("hello")'`;
112+
snapshot[`isArrayOf<T> > returns properly named function 1`] = `"isArrayOf(isNumber)"`;
62113
63-
snapshot[`isLiteralOf<T> > returns properly named function 2`] = `"isLiteralOf(100)"`;
114+
snapshot[`isArrayOf<T> > returns properly named function 2`] = `"isArrayOf((anonymous))"`;
64115
65-
snapshot[`isLiteralOf<T> > returns properly named function 3`] = `"isLiteralOf(100n)"`;
116+
snapshot[`isReadonlyTupleOf<T, E> > returns properly named function 1`] = `
117+
"isReadonlyTupleOf([
118+
isNumber,
119+
isString,
120+
isBoolean
121+
], isArray)"
122+
`;
66123
67-
snapshot[`isLiteralOf<T> > returns properly named function 4`] = `"isLiteralOf(true)"`;
124+
snapshot[`isReadonlyTupleOf<T, E> > returns properly named function 2`] = `"isReadonlyTupleOf([(anonymous)], isArrayOf(isString))"`;
68125
69-
snapshot[`isLiteralOf<T> > returns properly named function 5`] = `"isLiteralOf(null)"`;
126+
snapshot[`isReadonlyTupleOf<T, E> > returns properly named function 3`] = `
127+
"isReadonlyTupleOf([
128+
isReadonlyTupleOf([
129+
isReadonlyTupleOf([
130+
isNumber,
131+
isString,
132+
isBoolean
133+
], isArray)
134+
], isArray)
135+
], isArray)"
136+
`;
70137
71-
snapshot[`isLiteralOf<T> > returns properly named function 6`] = `"isLiteralOf(undefined)"`;
138+
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 1`] = `"isReadonlyUniformTupleOf(3, isAny)"`;
72139
73-
snapshot[`isLiteralOf<T> > returns properly named function 7`] = `"isLiteralOf(Symbol(asdf))"`;
140+
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 2`] = `"isReadonlyUniformTupleOf(3, isNumber)"`;
74141
75-
snapshot[`isLiteralOneOf<T> > returns properly named function 1`] = `'isLiteralOneOf(["hello", "world"])'`;
142+
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 3`] = `"isReadonlyUniformTupleOf(3, (anonymous))"`;
76143
77-
snapshot[`isOneOf<T> > returns properly named function 1`] = `
78-
"isOneOf([
144+
snapshot[`isReadonlyTupleOf<T> > returns properly named function 1`] = `
145+
"isReadonlyTupleOf([
79146
isNumber,
80147
isString,
81148
isBoolean
82149
])"
83150
`;
84151
85-
snapshot[`isAllOf<T> > returns properly named function 1`] = `
86-
"isAllOf([
87-
isObjectOf({a: isNumber}),
88-
isObjectOf({b: isString})
152+
snapshot[`isReadonlyTupleOf<T> > returns properly named function 2`] = `"isReadonlyTupleOf([(anonymous)])"`;
153+
154+
snapshot[`isReadonlyTupleOf<T> > returns properly named function 3`] = `
155+
"isReadonlyTupleOf([
156+
isReadonlyTupleOf([
157+
isReadonlyTupleOf([
158+
isNumber,
159+
isString,
160+
isBoolean
161+
])
162+
])
89163
])"
90164
`;
91-
92-
snapshot[`isOptionalOf<T> > returns properly named function 1`] = `"isOptionalOf(isNumber)"`;

0 commit comments

Comments
 (0)