schematox 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +8 -8
- package/dist/parse.js.map +1 -1
- package/package.json +3 -3
- package/src/tests/README.md +0 -390
- package/src/tests/by-struct/array.test.ts +0 -1684
- package/src/tests/by-struct/boolean.test.ts +0 -741
- package/src/tests/by-struct/literal.test.ts +0 -755
- package/src/tests/by-struct/number.test.ts +0 -1234
- package/src/tests/by-struct/object.test.ts +0 -1484
- package/src/tests/by-struct/record.test.ts +0 -1802
- package/src/tests/by-struct/string.test.ts +0 -1252
- package/src/tests/by-struct/tuple.test.ts +0 -1341
- package/src/tests/by-struct/union.test.ts +0 -1284
- package/src/tests/fixtures.ts +0 -53
- package/src/tests/fold-constants.ts +0 -247
- package/src/tests/fold-morph.ts +0 -49
- package/src/tests/type.ts +0 -1
- package/src/tests/types/extensions.test.ts +0 -117
- package/src/tests/types/infer.test.ts +0 -1413
- package/src/tests/utils.test.ts +0 -191
package/src/tests/fixtures.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export const DATA_TYPE = [
|
|
2
|
-
['boolean', [true, false]],
|
|
3
|
-
['literal', []], // added to be consistent with `foldC`
|
|
4
|
-
['number', [-1, -0.001, 0, 0.001, 1]],
|
|
5
|
-
['bigint', [BigInt(12)]],
|
|
6
|
-
['string', ['', 'x', 'xy', 'xyz']],
|
|
7
|
-
[
|
|
8
|
-
'binary',
|
|
9
|
-
[
|
|
10
|
-
// TODO: jest complains after #52 PR merge
|
|
11
|
-
// new Blob(),
|
|
12
|
-
new File([''], 'filename'),
|
|
13
|
-
new ArrayBuffer(0),
|
|
14
|
-
new DataView(new ArrayBuffer(0)),
|
|
15
|
-
new Int8Array(),
|
|
16
|
-
new Uint8Array(),
|
|
17
|
-
new Uint8ClampedArray(),
|
|
18
|
-
new Int16Array(),
|
|
19
|
-
new Uint16Array(),
|
|
20
|
-
new Int32Array(),
|
|
21
|
-
new Uint32Array(),
|
|
22
|
-
new Float32Array(),
|
|
23
|
-
new Float64Array(),
|
|
24
|
-
],
|
|
25
|
-
],
|
|
26
|
-
//
|
|
27
|
-
['null', [null]],
|
|
28
|
-
['NaN', [NaN]],
|
|
29
|
-
['undefined', [undefined]],
|
|
30
|
-
['infinity', [Infinity, -Infinity]],
|
|
31
|
-
['symbol', [Symbol('x'), Symbol('y')]],
|
|
32
|
-
//
|
|
33
|
-
['array', [[], ['x', 'y']]],
|
|
34
|
-
['object', [{}, { x: 'y' }]],
|
|
35
|
-
['record', []], // added to be consistent with `foldC`
|
|
36
|
-
['union', []], // added to be consistent with `foldC`
|
|
37
|
-
['tuple', []], // added to be consistent with `foldC`
|
|
38
|
-
['set', [new Set(), new WeakSet()]],
|
|
39
|
-
['map', [new Map(), new WeakMap()]],
|
|
40
|
-
['error', [new Error()]],
|
|
41
|
-
] as const satisfies Array<[type: string, variants: unknown[]]>
|
|
42
|
-
|
|
43
|
-
export const DATA_VARIANTS_BY_TYPE = DATA_TYPE.reduce<
|
|
44
|
-
Record<string, unknown[]>
|
|
45
|
-
>((acc, [type, variants]) => {
|
|
46
|
-
acc[type] = variants
|
|
47
|
-
return acc
|
|
48
|
-
}, {}) as {
|
|
49
|
-
[K in (typeof DATA_TYPE)[number][0]]: Extract<
|
|
50
|
-
(typeof DATA_TYPE)[number],
|
|
51
|
-
[K, unknown]
|
|
52
|
-
>[1]
|
|
53
|
-
}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
/* FOLDS must be in sync with `src/tests/README.md` */
|
|
2
|
-
|
|
3
|
-
const FOLD_A = `{
|
|
4
|
-
const construct = x.makeStruct(schema)
|
|
5
|
-
|
|
6
|
-
/* ensure that schema/construct/struct/~standard subject types are identical */
|
|
7
|
-
|
|
8
|
-
type ConstructSchemaSubj = x.Infer<typeof construct.__schema>
|
|
9
|
-
|
|
10
|
-
x.tCh<ConstructSchemaSubj, ExpectedSubj>()
|
|
11
|
-
x.tCh<ExpectedSubj, ConstructSchemaSubj>()
|
|
12
|
-
|
|
13
|
-
type SchemaSubj = x.Infer<typeof schema>
|
|
14
|
-
|
|
15
|
-
x.tCh<SchemaSubj, ExpectedSubj>()
|
|
16
|
-
x.tCh<ExpectedSubj, SchemaSubj>()
|
|
17
|
-
|
|
18
|
-
type StructSubj = x.Infer<typeof struct.__schema>
|
|
19
|
-
|
|
20
|
-
x.tCh<StructSubj, ExpectedSubj>()
|
|
21
|
-
x.tCh<ExpectedSubj, StructSubj>()
|
|
22
|
-
|
|
23
|
-
type StandardSubj = NonNullable<
|
|
24
|
-
(typeof struct)['~standard']['types']
|
|
25
|
-
>['output']
|
|
26
|
-
|
|
27
|
-
x.tCh<StandardSubj, ExpectedSubj>()
|
|
28
|
-
x.tCh<ExpectedSubj, StandardSubj>()
|
|
29
|
-
|
|
30
|
-
/* parsed either type check */
|
|
31
|
-
|
|
32
|
-
type ExpectedParsed = x.ParseResult<ExpectedSubj>
|
|
33
|
-
|
|
34
|
-
const parsed = x.parse(schema, undefined)
|
|
35
|
-
|
|
36
|
-
type SchemaParsed = typeof parsed
|
|
37
|
-
|
|
38
|
-
x.tCh<SchemaParsed, ExpectedParsed>()
|
|
39
|
-
x.tCh<ExpectedParsed, SchemaParsed>()
|
|
40
|
-
|
|
41
|
-
type ConstructParsed = ReturnType<typeof construct.parse>
|
|
42
|
-
|
|
43
|
-
x.tCh<ConstructParsed, ExpectedParsed>()
|
|
44
|
-
x.tCh<ExpectedParsed, ConstructParsed>()
|
|
45
|
-
|
|
46
|
-
type StructParsed = ReturnType<typeof struct.parse>
|
|
47
|
-
|
|
48
|
-
x.tCh<StructParsed, ExpectedParsed>()
|
|
49
|
-
x.tCh<ExpectedParsed, StructParsed>()
|
|
50
|
-
|
|
51
|
-
type StandardParsed = Extract<
|
|
52
|
-
ReturnType<(typeof struct)['~standard']['validate']>,
|
|
53
|
-
{ value: unknown }
|
|
54
|
-
>['value']
|
|
55
|
-
|
|
56
|
-
x.tCh<StandardParsed, ExpectedSubj>()
|
|
57
|
-
x.tCh<ExpectedSubj, StandardParsed>()
|
|
58
|
-
|
|
59
|
-
/* runtime schema check */
|
|
60
|
-
|
|
61
|
-
expect(struct.__schema).toStrictEqual(schema)
|
|
62
|
-
expect(construct.__schema).toStrictEqual(schema)
|
|
63
|
-
expect(construct.__schema === schema).toBe(false)
|
|
64
|
-
|
|
65
|
-
/* parse result check */
|
|
66
|
-
|
|
67
|
-
for (const subj of subjects) {
|
|
68
|
-
const schemaParsed = x.parse(schema, subj)
|
|
69
|
-
|
|
70
|
-
expect(schemaParsed.error).toBe(undefined)
|
|
71
|
-
expect(schemaParsed.data).toStrictEqual(subj)
|
|
72
|
-
|
|
73
|
-
const constructParsed = construct.parse(subj)
|
|
74
|
-
|
|
75
|
-
expect(constructParsed.error).toBe(undefined)
|
|
76
|
-
expect(constructParsed.data).toStrictEqual(subj)
|
|
77
|
-
|
|
78
|
-
const structParsed = struct.parse(subj)
|
|
79
|
-
|
|
80
|
-
expect(structParsed.error).toBe(undefined)
|
|
81
|
-
expect(structParsed.data).toStrictEqual(subj)
|
|
82
|
-
|
|
83
|
-
const standardParsed = struct['~standard'].validate(subj)
|
|
84
|
-
|
|
85
|
-
if (standardParsed instanceof Promise) {
|
|
86
|
-
throw Error('Not expected')
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (standardParsed.issues !== undefined) {
|
|
90
|
-
throw Error('not expected')
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
expect(standardParsed.value).toStrictEqual(subj)
|
|
94
|
-
}
|
|
95
|
-
}`
|
|
96
|
-
|
|
97
|
-
const FOLD_B = `{
|
|
98
|
-
const construct = x.makeStruct(schema)
|
|
99
|
-
|
|
100
|
-
/* ensure that struct keys are reduced after application */
|
|
101
|
-
|
|
102
|
-
type StructKeys = keyof typeof struct
|
|
103
|
-
|
|
104
|
-
x.tCh<StructKeys, ExpectedKeys>()
|
|
105
|
-
x.tCh<ExpectedKeys, StructKeys>()
|
|
106
|
-
|
|
107
|
-
type ConstructKeys = keyof typeof construct
|
|
108
|
-
|
|
109
|
-
x.tCh<ConstructKeys, ExpectedKeys>()
|
|
110
|
-
x.tCh<ExpectedKeys, ConstructKeys>()
|
|
111
|
-
|
|
112
|
-
/* ensure that construct/struct schema types are identical */
|
|
113
|
-
|
|
114
|
-
type ExpectedSchema = typeof schema
|
|
115
|
-
type StructSchema = typeof struct.__schema
|
|
116
|
-
|
|
117
|
-
x.tCh<StructSchema, ExpectedSchema>()
|
|
118
|
-
x.tCh<ExpectedSchema, StructSchema>()
|
|
119
|
-
|
|
120
|
-
type ConstructSchema = typeof struct.__schema
|
|
121
|
-
|
|
122
|
-
x.tCh<ConstructSchema, ExpectedSchema>()
|
|
123
|
-
x.tCh<ExpectedSchema, ConstructSchema>()
|
|
124
|
-
|
|
125
|
-
/* runtime schema check */
|
|
126
|
-
|
|
127
|
-
expect(struct.__schema).toStrictEqual(schema)
|
|
128
|
-
expect(construct.__schema).toStrictEqual(schema)
|
|
129
|
-
expect(construct.__schema === schema).toBe(false)
|
|
130
|
-
|
|
131
|
-
/* runtime schema parameter application immutability check */
|
|
132
|
-
|
|
133
|
-
expect(prevStruct.__schema === struct.__schema).toBe(false)
|
|
134
|
-
}`
|
|
135
|
-
|
|
136
|
-
const FOLD_C = `{
|
|
137
|
-
const construct = x.makeStruct(schema)
|
|
138
|
-
|
|
139
|
-
for (const [kind, types] of source) {
|
|
140
|
-
if (kind === schema.type) {
|
|
141
|
-
continue
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
for (const subject of types) {
|
|
145
|
-
const expectedError = [
|
|
146
|
-
{
|
|
147
|
-
code: x.ERROR_CODE.invalidType,
|
|
148
|
-
schema: schema,
|
|
149
|
-
subject: subject,
|
|
150
|
-
path: [],
|
|
151
|
-
},
|
|
152
|
-
]
|
|
153
|
-
|
|
154
|
-
const parsedSchema = x.parse(schema, subject)
|
|
155
|
-
const parsedConstruct = construct.parse(subject)
|
|
156
|
-
const parsedStruct = struct.parse(subject)
|
|
157
|
-
|
|
158
|
-
expect(parsedSchema.error).toStrictEqual(expectedError)
|
|
159
|
-
expect(parsedConstruct.error).toStrictEqual(expectedError)
|
|
160
|
-
expect(parsedStruct.error).toStrictEqual(expectedError)
|
|
161
|
-
|
|
162
|
-
const parsedStandard = struct['~standard'].validate(subject)
|
|
163
|
-
|
|
164
|
-
if (parsedStandard instanceof Promise) {
|
|
165
|
-
throw Error('Not expected')
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
expect(parsedStandard.issues).toStrictEqual([
|
|
169
|
-
{ message: x.ERROR_CODE.invalidType, path: [] },
|
|
170
|
-
])
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}`
|
|
174
|
-
|
|
175
|
-
const FOLD_D = `{
|
|
176
|
-
const construct = x.makeStruct(schema)
|
|
177
|
-
|
|
178
|
-
for (const subject of subjects) {
|
|
179
|
-
const expectedError = [
|
|
180
|
-
{
|
|
181
|
-
code: x.ERROR_CODE.invalidRange,
|
|
182
|
-
schema: schema,
|
|
183
|
-
subject: subject,
|
|
184
|
-
path: [],
|
|
185
|
-
},
|
|
186
|
-
]
|
|
187
|
-
|
|
188
|
-
const parsedSchema = x.parse(schema, subject)
|
|
189
|
-
const parsedConstruct = construct.parse(subject)
|
|
190
|
-
const parsedStruct = struct.parse(subject)
|
|
191
|
-
|
|
192
|
-
expect(parsedSchema.error).toStrictEqual(expectedError)
|
|
193
|
-
expect(parsedConstruct.error).toStrictEqual(expectedError)
|
|
194
|
-
expect(parsedStruct.error).toStrictEqual(expectedError)
|
|
195
|
-
|
|
196
|
-
const parsedStandard = struct['~standard'].validate(subject)
|
|
197
|
-
|
|
198
|
-
if (parsedStandard instanceof Promise) {
|
|
199
|
-
throw Error('Not expected')
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
expect(parsedStandard.issues).toStrictEqual([
|
|
203
|
-
{ message: x.ERROR_CODE.invalidRange, path: [] },
|
|
204
|
-
])
|
|
205
|
-
}
|
|
206
|
-
}`
|
|
207
|
-
|
|
208
|
-
const FOLD_E = `{
|
|
209
|
-
const construct = x.makeStruct(schema)
|
|
210
|
-
|
|
211
|
-
for (const [subject, invalidSubj, invalidSubjSchema, path] of samples) {
|
|
212
|
-
const expectedError = [
|
|
213
|
-
{
|
|
214
|
-
path,
|
|
215
|
-
code: x.ERROR_CODE.invalidType,
|
|
216
|
-
schema: invalidSubjSchema,
|
|
217
|
-
subject: invalidSubj,
|
|
218
|
-
},
|
|
219
|
-
]
|
|
220
|
-
|
|
221
|
-
const parsedSchema = x.parse(schema, subject)
|
|
222
|
-
const parsedConstruct = construct.parse(subject)
|
|
223
|
-
const parsedStruct = struct.parse(subject)
|
|
224
|
-
|
|
225
|
-
expect(parsedSchema.error).toStrictEqual(expectedError)
|
|
226
|
-
expect(parsedConstruct.error).toStrictEqual(expectedError)
|
|
227
|
-
expect(parsedStruct.error).toStrictEqual(expectedError)
|
|
228
|
-
|
|
229
|
-
const parsedStandard = struct['~standard'].validate(subject)
|
|
230
|
-
|
|
231
|
-
if (parsedStandard instanceof Promise) {
|
|
232
|
-
throw Error('Not expected')
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
expect(parsedStandard.issues).toStrictEqual([
|
|
236
|
-
{ path, message: x.ERROR_CODE.invalidType },
|
|
237
|
-
])
|
|
238
|
-
}
|
|
239
|
-
}`
|
|
240
|
-
|
|
241
|
-
export const FOLDS: Array<[label: string, content: string]> = [
|
|
242
|
-
['foldA', FOLD_A],
|
|
243
|
-
['foldB', FOLD_B],
|
|
244
|
-
['foldC', FOLD_C],
|
|
245
|
-
['foldD', FOLD_D],
|
|
246
|
-
['foldE', FOLD_E],
|
|
247
|
-
]
|
package/src/tests/fold-morph.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Project, SyntaxKind } from 'ts-morph'
|
|
2
|
-
import { FOLDS } from './fold-constants'
|
|
3
|
-
|
|
4
|
-
const FILE_PATHS = [
|
|
5
|
-
'src/tests/by-struct/boolean.test.ts',
|
|
6
|
-
'src/tests/by-struct/literal.test.ts',
|
|
7
|
-
'src/tests/by-struct/number.test.ts',
|
|
8
|
-
'src/tests/by-struct/string.test.ts',
|
|
9
|
-
//
|
|
10
|
-
'src/tests/by-struct/array.test.ts',
|
|
11
|
-
'src/tests/by-struct/object.test.ts',
|
|
12
|
-
'src/tests/by-struct/record.test.ts',
|
|
13
|
-
'src/tests/by-struct/tuple.test.ts',
|
|
14
|
-
'src/tests/by-struct/union.test.ts',
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
for (const filePath of FILE_PATHS) {
|
|
18
|
-
for (const [foldLabel, foldContent] of FOLDS) {
|
|
19
|
-
foldSync({ filePath, foldLabel, foldContent })
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function foldSync(props: {
|
|
24
|
-
filePath: string
|
|
25
|
-
foldLabel: string
|
|
26
|
-
foldContent: string
|
|
27
|
-
}) {
|
|
28
|
-
const project = new Project()
|
|
29
|
-
const sourceFile = project.addSourceFileAtPath(props.filePath)
|
|
30
|
-
|
|
31
|
-
const labeledStatements = sourceFile.getDescendantsOfKind(
|
|
32
|
-
SyntaxKind.LabeledStatement
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
for (const labeledStatement of labeledStatements) {
|
|
36
|
-
const label = labeledStatement.getLabel()
|
|
37
|
-
|
|
38
|
-
if (label.getText() === props.foldLabel) {
|
|
39
|
-
const statement = labeledStatement.getStatement()
|
|
40
|
-
|
|
41
|
-
if (statement.getKind() === SyntaxKind.Block) {
|
|
42
|
-
const blockStatement = statement.asKindOrThrow(SyntaxKind.Block)
|
|
43
|
-
blockStatement.replaceWithText(props.foldContent)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
sourceFile.saveSync()
|
|
49
|
-
}
|
package/src/tests/type.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type StructSharedKeys = '__schema' | '~standard' | 'parse'
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import * as x from '../../index'
|
|
2
|
-
|
|
3
|
-
describe('ExtWith_SchemaParams_SubjT<T, U>: U is primitive', () => {
|
|
4
|
-
type U = boolean
|
|
5
|
-
|
|
6
|
-
it('extend nothing if parameters are not specified', () => {
|
|
7
|
-
const schema = {} as const
|
|
8
|
-
|
|
9
|
-
type Expected = U
|
|
10
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
11
|
-
|
|
12
|
-
x.tCh<Expected, Actual>()
|
|
13
|
-
x.tCh<Actual, Expected>()
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('optional', () => {
|
|
17
|
-
const schema = { optional: true } as const
|
|
18
|
-
|
|
19
|
-
type Expected = U | undefined
|
|
20
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
21
|
-
|
|
22
|
-
x.tCh<Actual, Expected>()
|
|
23
|
-
x.tCh<Expected, Actual>()
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('nullable', () => {
|
|
27
|
-
const schema = { nullable: true } as const
|
|
28
|
-
|
|
29
|
-
type Expected = U | null
|
|
30
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
31
|
-
|
|
32
|
-
x.tCh<Actual, Expected>()
|
|
33
|
-
x.tCh<Expected, Actual>()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('brand', () => {
|
|
37
|
-
const schema = { brand: ['x', 'y'] } as const
|
|
38
|
-
|
|
39
|
-
type Expected = U & { __x: 'y' }
|
|
40
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
41
|
-
|
|
42
|
-
x.tCh<Actual, Expected>()
|
|
43
|
-
x.tCh<Expected, Actual>()
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('optional + nullable + brand', () => {
|
|
47
|
-
const schema = {
|
|
48
|
-
optional: true,
|
|
49
|
-
nullable: true,
|
|
50
|
-
brand: ['x', 'y'],
|
|
51
|
-
} as const
|
|
52
|
-
|
|
53
|
-
type Expected = (U & { __x: 'y' }) | null | undefined
|
|
54
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
55
|
-
|
|
56
|
-
x.tCh<Actual, Expected>()
|
|
57
|
-
x.tCh<Expected, Actual>()
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
describe('ExtWith_SchemaParams_SubjT<T, U>: U is object', () => {
|
|
62
|
-
type U = { x: string; y: number }
|
|
63
|
-
|
|
64
|
-
it('extend nothing if parameters are not specified', () => {
|
|
65
|
-
const schema = {} as const
|
|
66
|
-
|
|
67
|
-
type Expected = U
|
|
68
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
69
|
-
|
|
70
|
-
x.tCh<Actual, Expected>()
|
|
71
|
-
x.tCh<Expected, Actual>()
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('optional', () => {
|
|
75
|
-
const schema = { optional: true } as const
|
|
76
|
-
|
|
77
|
-
type Expected = U | undefined
|
|
78
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
79
|
-
|
|
80
|
-
x.tCh<Actual, Expected>()
|
|
81
|
-
x.tCh<Expected, Actual>()
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('nullable', () => {
|
|
85
|
-
const schema = { nullable: true } as const
|
|
86
|
-
|
|
87
|
-
type Expected = U | null
|
|
88
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
89
|
-
|
|
90
|
-
x.tCh<Actual, Expected>()
|
|
91
|
-
x.tCh<Expected, Actual>()
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it('brand', () => {
|
|
95
|
-
const schema = { brand: ['x', 'y'] } as const
|
|
96
|
-
|
|
97
|
-
type Expected = U & { __x: 'y' }
|
|
98
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
99
|
-
|
|
100
|
-
x.tCh<Actual, Expected>()
|
|
101
|
-
x.tCh<Expected, Actual>()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('optional + nullable + brand', () => {
|
|
105
|
-
const schema = {
|
|
106
|
-
optional: true,
|
|
107
|
-
nullable: true,
|
|
108
|
-
brand: ['x', 'y'],
|
|
109
|
-
} as const
|
|
110
|
-
|
|
111
|
-
type Expected = (U & { __x: 'y' }) | null | undefined
|
|
112
|
-
type Actual = x.ExtendParams<typeof schema, U>
|
|
113
|
-
|
|
114
|
-
x.tCh<Actual, Expected>()
|
|
115
|
-
x.tCh<Expected, Actual>()
|
|
116
|
-
})
|
|
117
|
-
})
|