Skip to content

Commit bd9a951

Browse files
authored
Merge pull request #59 from lambdalisue/fix-readonly
📝 Note that `isReadonlyOf` and related are **unstable**
2 parents 5b4795c + 8f1b11a commit bd9a951

File tree

9 files changed

+356
-151
lines changed

9 files changed

+356
-151
lines changed

is.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
import _deprecated from "./is/_deprecated.ts";
12
import annotation from "./is/annotation.ts";
23
import core from "./is/core.ts";
34
import factory from "./is/factory.ts";
45
import utility from "./is/utility.ts";
56

6-
export type * from "./is/type.ts";
7+
export * from "./is/_deprecated.ts";
78
export * from "./is/annotation.ts";
89
export * from "./is/core.ts";
910
export * from "./is/factory.ts";
1011
export * from "./is/utility.ts";
12+
export type * from "./is/type.ts";
1113

1214
export default {
15+
..._deprecated,
1316
...annotation,
1417
...core,
1518
...factory,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const snapshot = {};
2+
3+
snapshot[`isAllOf<T> > returns properly named function 1`] = `
4+
"isObjectOf({
5+
a: isNumber,
6+
b: isString
7+
})"
8+
`;
9+
10+
snapshot[`isOneOf<T> > returns properly named function 1`] = `
11+
"isUnionOf([
12+
isNumber,
13+
isString,
14+
isBoolean
15+
])"
16+
`;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
export const snapshot = {};
22

3+
snapshot[`isOptionalOf<T> > returns properly named function 1`] = `"isOptionalOf(isNumber)"`;
4+
5+
snapshot[`isOptionalOf<T> > returns properly named function 2`] = `"isOptionalOf(isNumber)"`;
6+
37
snapshot[`isUnwrapOptionalOf<T> > returns properly named function 1`] = `"isNumber"`;
48
59
snapshot[`isUnwrapOptionalOf<T> > returns properly named function 2`] = `"isNumber"`;
610
711
snapshot[`isUnwrapOptionalOf<T> > returns properly named function 3`] = `"isNumber"`;
812
9-
snapshot[`isOptionalOf<T> > returns properly named function 1`] = `"isOptionalOf(isNumber)"`;
13+
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 1`] = `"isNumber"`;
1014
11-
snapshot[`isOptionalOf<T> > returns properly named function 2`] = `"isOptionalOf(isNumber)"`;
15+
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 2`] = `"isReadonlyOf(isNumber)"`;
1216
1317
snapshot[`isReadonlyOf<T> > returns properly named function 1`] = `"isReadonlyOf(isNumber)"`;
1418
1519
snapshot[`isReadonlyOf<T> > returns properly named function 2`] = `"isReadonlyOf(isReadonlyOf(isNumber))"`;
16-
17-
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 1`] = `"isNumber"`;
18-
19-
snapshot[`isUnwrapReadonlyOf<T> > returns properly named function 2`] = `"isReadonlyOf(isNumber)"`;
Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
export const snapshot = {};
22

3-
snapshot[`isMapOf<T> > returns properly named function 1`] = `"isMapOf(isNumber, undefined)"`;
4-
5-
snapshot[`isMapOf<T> > returns properly named function 2`] = `"isMapOf((anonymous), undefined)"`;
6-
73
snapshot[`isObjectOf<T> > returns properly named function 1`] = `
84
"isObjectOf({
95
a: isNumber,
@@ -22,6 +18,36 @@ snapshot[`isObjectOf<T> > returns properly named function 3`] = `
2218
})"
2319
`;
2420
21+
snapshot[`isArrayOf<T> > returns properly named function 1`] = `"isArrayOf(isNumber)"`;
22+
23+
snapshot[`isArrayOf<T> > returns properly named function 2`] = `"isArrayOf((anonymous))"`;
24+
25+
snapshot[`isReadonlyTupleOf<T> > returns properly named function 1`] = `
26+
"isReadonlyOf(isTupleOf([
27+
isNumber,
28+
isString,
29+
isBoolean
30+
]))"
31+
`;
32+
33+
snapshot[`isReadonlyTupleOf<T> > returns properly named function 2`] = `"isReadonlyOf(isTupleOf([(anonymous)]))"`;
34+
35+
snapshot[`isReadonlyTupleOf<T> > returns properly named function 3`] = `
36+
"isReadonlyOf(isTupleOf([
37+
isReadonlyOf(isTupleOf([
38+
isReadonlyOf(isTupleOf([
39+
isNumber,
40+
isString,
41+
isBoolean
42+
]))
43+
]))
44+
]))"
45+
`;
46+
47+
snapshot[`isSetOf<T> > returns properly named function 1`] = `"isSetOf(isNumber)"`;
48+
49+
snapshot[`isSetOf<T> > returns properly named function 2`] = `"isSetOf((anonymous))"`;
50+
2551
snapshot[`isTupleOf<T> > returns properly named function 1`] = `
2652
"isTupleOf([
2753
isNumber,
@@ -48,38 +74,6 @@ snapshot[`isRecordOf<T> > returns properly named function 1`] = `"isRecordOf(isN
4874
4975
snapshot[`isRecordOf<T> > returns properly named function 2`] = `"isRecordOf((anonymous), undefined)"`;
5076
51-
snapshot[`isLiteralOf<T> > returns properly named function 1`] = `'isLiteralOf("hello")'`;
52-
53-
snapshot[`isLiteralOf<T> > returns properly named function 2`] = `"isLiteralOf(100)"`;
54-
55-
snapshot[`isLiteralOf<T> > returns properly named function 3`] = `"isLiteralOf(100n)"`;
56-
57-
snapshot[`isLiteralOf<T> > returns properly named function 4`] = `"isLiteralOf(true)"`;
58-
59-
snapshot[`isLiteralOf<T> > returns properly named function 5`] = `"isLiteralOf(null)"`;
60-
61-
snapshot[`isLiteralOf<T> > returns properly named function 6`] = `"isLiteralOf(undefined)"`;
62-
63-
snapshot[`isLiteralOf<T> > returns properly named function 7`] = `"isLiteralOf(Symbol(asdf))"`;
64-
65-
snapshot[`isStrictOf<T> > returns properly named function 1`] = `
66-
"isStrictOf(isObjectOf({
67-
a: isNumber,
68-
b: isString,
69-
c: isBoolean
70-
}))"
71-
`;
72-
73-
snapshot[`isStrictOf<T> > returns properly named function 2`] = `"isStrictOf(isObjectOf({a: a}))"`;
74-
75-
snapshot[`isStrictOf<T> > returns properly named function 3`] = `
76-
"isStrictOf(isObjectOf({
77-
a: isStrictOf(isObjectOf({
78-
b: isStrictOf(isObjectOf({c: isBoolean}))
79-
}))
80-
}))"
81-
`;
82-
8377
snapshot[`isReadonlyTupleOf<T, E> > returns properly named function 1`] = `
8478
"isReadonlyOf(isTupleOf([
8579
isNumber,
@@ -102,80 +96,86 @@ snapshot[`isReadonlyTupleOf<T, E> > returns properly named function 3`] = `
10296
], isArray))"
10397
`;
10498
105-
snapshot[`isMapOf<T, K> > returns properly named function 1`] = `"isMapOf(isNumber, isString)"`;
99+
snapshot[`isTupleOf<T, E> > returns properly named function 1`] = `
100+
"isTupleOf([
101+
isNumber,
102+
isString,
103+
isBoolean
104+
], isArray)"
105+
`;
106106
107-
snapshot[`isMapOf<T, K> > returns properly named function 2`] = `"isMapOf((anonymous), isString)"`;
107+
snapshot[`isTupleOf<T, E> > returns properly named function 2`] = `"isTupleOf([(anonymous)], isArrayOf(isString))"`;
108+
109+
snapshot[`isTupleOf<T, E> > returns properly named function 3`] = `
110+
"isTupleOf([
111+
isTupleOf([
112+
isTupleOf([
113+
isNumber,
114+
isString,
115+
isBoolean
116+
], isArray)
117+
], isArray)
118+
])"
119+
`;
120+
121+
snapshot[`isInstanceOf<T> > returns properly named function 1`] = `"isInstanceOf(Date)"`;
122+
123+
snapshot[`isInstanceOf<T> > returns properly named function 2`] = `"isInstanceOf((anonymous))"`;
108124
109125
snapshot[`isLiteralOneOf<T> > returns properly named function 1`] = `'isLiteralOneOf(["hello", "world"])'`;
110126
127+
snapshot[`isMapOf<T> > returns properly named function 1`] = `"isMapOf(isNumber, undefined)"`;
128+
129+
snapshot[`isMapOf<T> > returns properly named function 2`] = `"isMapOf((anonymous), undefined)"`;
130+
131+
snapshot[`isStrictOf<T> > returns properly named function 1`] = `
132+
"isStrictOf(isObjectOf({
133+
a: isNumber,
134+
b: isString,
135+
c: isBoolean
136+
}))"
137+
`;
138+
139+
snapshot[`isStrictOf<T> > returns properly named function 2`] = `"isStrictOf(isObjectOf({a: a}))"`;
140+
141+
snapshot[`isStrictOf<T> > returns properly named function 3`] = `
142+
"isStrictOf(isObjectOf({
143+
a: isStrictOf(isObjectOf({
144+
b: isStrictOf(isObjectOf({c: isBoolean}))
145+
}))
146+
}))"
147+
`;
148+
111149
snapshot[`isRecordOf<T, K> > returns properly named function 1`] = `"isRecordOf(isNumber, isString)"`;
112150
113151
snapshot[`isRecordOf<T, K> > returns properly named function 2`] = `"isRecordOf((anonymous), isString)"`;
114152
115-
snapshot[`isArrayOf<T> > returns properly named function 1`] = `"isArrayOf(isNumber)"`;
153+
snapshot[`isLiteralOf<T> > returns properly named function 1`] = `'isLiteralOf("hello")'`;
116154
117-
snapshot[`isArrayOf<T> > returns properly named function 2`] = `"isArrayOf((anonymous))"`;
155+
snapshot[`isLiteralOf<T> > returns properly named function 2`] = `"isLiteralOf(100)"`;
118156
119-
snapshot[`isInstanceOf<T> > returns properly named function 1`] = `"isInstanceOf(Date)"`;
157+
snapshot[`isLiteralOf<T> > returns properly named function 3`] = `"isLiteralOf(100n)"`;
120158
121-
snapshot[`isInstanceOf<T> > returns properly named function 2`] = `"isInstanceOf((anonymous))"`;
159+
snapshot[`isLiteralOf<T> > returns properly named function 4`] = `"isLiteralOf(true)"`;
122160
123-
snapshot[`isReadonlyTupleOf<T> > returns properly named function 1`] = `
124-
"isReadonlyOf(isTupleOf([
125-
isNumber,
126-
isString,
127-
isBoolean
128-
]))"
129-
`;
161+
snapshot[`isLiteralOf<T> > returns properly named function 5`] = `"isLiteralOf(null)"`;
130162
131-
snapshot[`isReadonlyTupleOf<T> > returns properly named function 2`] = `"isReadonlyOf(isTupleOf([(anonymous)]))"`;
163+
snapshot[`isLiteralOf<T> > returns properly named function 6`] = `"isLiteralOf(undefined)"`;
132164
133-
snapshot[`isReadonlyTupleOf<T> > returns properly named function 3`] = `
134-
"isReadonlyOf(isTupleOf([
135-
isReadonlyOf(isTupleOf([
136-
isReadonlyOf(isTupleOf([
137-
isNumber,
138-
isString,
139-
isBoolean
140-
]))
141-
]))
142-
]))"
143-
`;
165+
snapshot[`isLiteralOf<T> > returns properly named function 7`] = `"isLiteralOf(Symbol(asdf))"`;
166+
167+
snapshot[`isMapOf<T, K> > returns properly named function 1`] = `"isMapOf(isNumber, isString)"`;
168+
169+
snapshot[`isMapOf<T, K> > returns properly named function 2`] = `"isMapOf((anonymous), isString)"`;
144170
145171
snapshot[`isUniformTupleOf<T> > returns properly named function 1`] = `"isUniformTupleOf(3, isAny)"`;
146172
147173
snapshot[`isUniformTupleOf<T> > returns properly named function 2`] = `"isUniformTupleOf(3, isNumber)"`;
148174
149175
snapshot[`isUniformTupleOf<T> > returns properly named function 3`] = `"isUniformTupleOf(3, (anonymous))"`;
150176
151-
snapshot[`isSetOf<T> > returns properly named function 1`] = `"isSetOf(isNumber)"`;
152-
153-
snapshot[`isSetOf<T> > returns properly named function 2`] = `"isSetOf((anonymous))"`;
154-
155177
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 1`] = `"isReadonlyOf(isUniformTupleOf(3, isAny))"`;
156178
157179
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 2`] = `"isReadonlyOf(isUniformTupleOf(3, isNumber))"`;
158180
159181
snapshot[`isReadonlyUniformTupleOf<T> > returns properly named function 3`] = `"isReadonlyOf(isUniformTupleOf(3, (anonymous)))"`;
160-
161-
snapshot[`isTupleOf<T, E> > returns properly named function 1`] = `
162-
"isTupleOf([
163-
isNumber,
164-
isString,
165-
isBoolean
166-
], isArray)"
167-
`;
168-
169-
snapshot[`isTupleOf<T, E> > returns properly named function 2`] = `"isTupleOf([(anonymous)], isArrayOf(isString))"`;
170-
171-
snapshot[`isTupleOf<T, E> > returns properly named function 3`] = `
172-
"isTupleOf([
173-
isTupleOf([
174-
isTupleOf([
175-
isNumber,
176-
isString,
177-
isBoolean
178-
], isArray)
179-
], isArray)
180-
])"
181-
`;

is/__snapshots__/utility_test.ts.snap

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
export const snapshot = {};
22

3-
snapshot[`isRequiredOf<T> > returns properly named function 1`] = `
4-
"isObjectOf({
5-
a: isNumber,
6-
b: isUnionOf([
7-
isString,
8-
isUndefined
9-
]),
10-
c: isBoolean
11-
})"
12-
`;
13-
14-
snapshot[`isRequiredOf<T> > returns properly named function 2`] = `
15-
"isObjectOf({
16-
a: isNumber,
17-
b: isUnionOf([
18-
isString,
19-
isUndefined
20-
]),
21-
c: isBoolean
22-
})"
23-
`;
24-
253
snapshot[`isUnionOf<T> > returns properly named function 1`] = `
264
"isUnionOf([
275
isNumber,
@@ -61,18 +39,40 @@ snapshot[`isPartialOf<T> > returns properly named function 2`] = `
6139
})"
6240
`;
6341
64-
snapshot[`isIntersectionOf<T> > returns properly named function 1`] = `
42+
snapshot[`isPickOf<T, K> > returns properly named function 1`] = `
6543
"isObjectOf({
6644
a: isNumber,
67-
b: isString
45+
c: isBoolean
6846
})"
6947
`;
7048
71-
snapshot[`isPickOf<T, K> > returns properly named function 1`] = `
49+
snapshot[`isPickOf<T, K> > returns properly named function 2`] = `"isObjectOf({a: isNumber})"`;
50+
51+
snapshot[`isRequiredOf<T> > returns properly named function 1`] = `
7252
"isObjectOf({
7353
a: isNumber,
54+
b: isUnionOf([
55+
isString,
56+
isUndefined
57+
]),
7458
c: isBoolean
7559
})"
7660
`;
7761
78-
snapshot[`isPickOf<T, K> > returns properly named function 2`] = `"isObjectOf({a: isNumber})"`;
62+
snapshot[`isRequiredOf<T> > returns properly named function 2`] = `
63+
"isObjectOf({
64+
a: isNumber,
65+
b: isUnionOf([
66+
isString,
67+
isUndefined
68+
]),
69+
c: isBoolean
70+
})"
71+
`;
72+
73+
snapshot[`isIntersectionOf<T> > returns properly named function 1`] = `
74+
"isObjectOf({
75+
a: isNumber,
76+
b: isString
77+
})"
78+
`;

0 commit comments

Comments
 (0)