@strictly/define 0.0.1 → 0.0.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/.out/index.d.ts +17 -11
- package/.out/index.js +17 -11
- package/.out/transformers/copies/copy.d.ts +3 -3
- package/.out/transformers/copies/copy_to.d.ts +3 -3
- package/.out/transformers/copies/copy_to.js +4 -0
- package/.out/transformers/copies/mobx_copy.d.ts +4 -4
- package/.out/transformers/copies/mobx_copy.js +1 -1
- package/.out/transformers/copies/specs/copy_to.tests.js +8 -8
- package/.out/transformers/copies/specs/mobx_copy.tests.js +1 -1
- package/.out/transformers/flatteners/flatten_accessors_of_type.d.ts +5 -0
- package/.out/transformers/flatteners/flatten_accessors_of_type.js +11 -0
- package/.out/transformers/flatteners/flatten_json_value_to_type_paths_of.d.ts +2 -2
- package/.out/transformers/flatteners/flatten_json_value_to_type_paths_of.js +2 -2
- package/.out/transformers/flatteners/{flatten_type_def_to.d.ts → flatten_type_to.d.ts} +1 -1
- package/.out/transformers/flatteners/{flatten_type_def_to.js → flatten_type_to.js} +1 -1
- package/.out/transformers/flatteners/{flatten_type_defs_of.d.ts → flatten_types_of_type.d.ts} +1 -1
- package/.out/transformers/flatteners/flatten_types_of_type.js +7 -0
- package/.out/transformers/flatteners/flatten_validation_errors_of_type.d.ts +22 -0
- package/.out/transformers/flatteners/flatten_validation_errors_of_type.js +10 -0
- package/.out/transformers/flatteners/flatten_validators_of_validating_type.d.ts +4 -0
- package/.out/transformers/flatteners/flatten_validators_of_validating_type.js +17 -0
- package/.out/transformers/flatteners/{flatten_value_type_to.d.ts → flatten_value_to.d.ts} +4 -4
- package/.out/transformers/flatteners/{flatten_value_type_to.js → flatten_value_to.js} +7 -2
- package/.out/transformers/flatteners/flatten_values_of_type.d.ts +3 -0
- package/.out/transformers/flatteners/flatten_values_of_type.js +7 -0
- package/.out/transformers/flatteners/specs/{flatten_accessors_of.tests.js → flatten_accessors_of_type.tests.js} +5 -6
- package/.out/transformers/flatteners/specs/flatten_json_value_to_type_paths_of.tests.js +6 -6
- package/.out/transformers/flatteners/specs/{flatten_type_def_to.tests.js → flatten_type_to.tests.js} +15 -13
- package/.out/transformers/flatteners/specs/flatten_types_of_type.tests.js +18 -0
- package/.out/transformers/flatteners/specs/flatten_validation_errors_of_type.tests.js +25 -0
- package/.out/transformers/flatteners/specs/{flatten_value_type_to.tests.js → flatten_value_to.tests.js} +81 -58
- package/.out/transformers/flatteners/specs/{flatten_value_types_of.tests.js → flatten_values_of_type.tests.js} +4 -4
- package/.out/transformers/flatteners/specs/value_path_to_type_path.tests.js +5 -3
- package/.out/transformers/flatteners/value_path_to_type_path.d.ts +1 -1
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/types/builders.d.ts +55 -29
- package/.out/types/builders.js +116 -32
- package/.out/types/definitions.d.ts +1 -1
- package/.out/types/flattened_accessors_of_type.d.ts +9 -0
- package/.out/types/{flattened_type_defs_of.d.ts → flattened_types_of_type.d.ts} +9 -6
- package/.out/types/flattened_types_of_validating_type.d.ts +25 -0
- package/.out/types/flattened_validators_of_validating_type.d.ts +10 -0
- package/.out/types/flattened_values_of_type.d.ts +6 -0
- package/.out/types/{mobx_value_type_of.d.ts → mobx_value_of_type.d.ts} +2 -2
- package/.out/types/{partial_type_def_of.d.ts → partial_type_of_type.d.ts} +1 -1
- package/.out/types/path_of.d.ts +1 -0
- package/.out/types/{json_paths_of.d.ts → paths_of_type.d.ts} +5 -5
- package/.out/types/readonly_type_of_type.d.ts +29 -0
- package/.out/types/specs/builder.tests.js +73 -23
- package/.out/types/specs/{flattened_accessors_of.tests.js → flattened_accessors_of_type.tests.js} +1 -1
- package/.out/types/specs/{flattened_type_defs_of.tests.js → flattened_types_of_type.tests.js} +22 -15
- package/.out/types/specs/flattened_validators_of_validating_type.tests.js +24 -0
- package/.out/types/specs/flattened_values_of_type.tests.js +18 -0
- package/.out/types/specs/{partial_type_def_of.tests.js → partial_type_of_type.tests.js} +4 -4
- package/.out/types/specs/{json_paths_of.tests.js → paths_of_type.tests.js} +19 -19
- package/.out/types/specs/{readonly_type_def_of.tests.js → readonly_type_of_type.tests.js} +6 -6
- package/.out/types/specs/type_of_type.tests.d.ts +1 -0
- package/.out/types/specs/type_of_type.tests.js +27 -0
- package/.out/types/specs/value_of_type.tests.d.ts +1 -0
- package/.out/types/specs/{value_type_of.tests.js → value_of_type.tests.js} +1 -1
- package/.out/types/specs/value_to_type_paths_of_type.tests.d.ts +1 -0
- package/.out/types/specs/{value_to_type_paths_of.tests.js → value_to_type_paths_of_type.tests.js} +9 -9
- package/.out/types/specs/value_types_of_discriminated_union.tests.js +2 -2
- package/.out/types/strict_definitions.d.ts +2 -2
- package/.out/types/type_of_type.d.ts +49 -0
- package/.out/types/type_of_type.js +70 -0
- package/.out/types/validating_definitions.d.ts +49 -0
- package/.out/types/validating_definitions.js +1 -0
- package/.out/types/validating_type_def_with_error.d.ts +55 -0
- package/.out/types/validating_type_def_with_error.js +1 -0
- package/.out/types/value_of_type.d.ts +24 -0
- package/.out/types/value_of_type.js +1 -0
- package/.out/types/{value_to_type_paths_of.d.ts → value_to_type_paths_of_type.d.ts} +13 -13
- package/.out/types/value_to_type_paths_of_type.js +1 -0
- package/.out/types/value_types_of_discriminated_union.d.ts +5 -4
- package/.out/validation/errors_of_validators.d.ts +4 -0
- package/.out/validation/errors_of_validators.js +1 -0
- package/.out/validation/specs/errors_of_validators.tests.d.ts +1 -0
- package/.out/validation/specs/errors_of_validators.tests.js +9 -0
- package/.out/validation/specs/validators_of_values.tests.d.ts +1 -0
- package/.out/validation/specs/validators_of_values.tests.js +21 -0
- package/.out/validation/validator.d.ts +21 -0
- package/.out/validation/validator.js +26 -0
- package/.out/validation/validators/defined_validator.d.ts +10 -0
- package/.out/validation/validators/defined_validator.js +18 -0
- package/.out/validation/validators/minimum_string_length_validator.d.ts +16 -0
- package/.out/validation/validators/minimum_string_length_validator.js +23 -0
- package/.out/validation/validators_of_values.d.ts +4 -0
- package/.out/validation/validators_of_values.js +1 -0
- package/.turbo/turbo-build.log +9 -9
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-release$colon$exports.log +1 -1
- package/README.md +16 -2
- package/dist/index.cjs +364 -76
- package/dist/index.d.cts +365 -114
- package/dist/index.d.ts +365 -114
- package/dist/index.js +355 -73
- package/index.ts +17 -11
- package/package.json +11 -3
- package/transformers/copies/copy.ts +4 -4
- package/transformers/copies/copy_to.ts +11 -7
- package/transformers/copies/mobx_copy.ts +6 -6
- package/transformers/copies/specs/copy_to.tests.ts +8 -8
- package/transformers/copies/specs/mobx_copy.tests.ts +3 -3
- package/transformers/flatteners/{flatten_accessors_of.ts → flatten_accessors_of_type.ts} +10 -10
- package/transformers/flatteners/flatten_json_value_to_type_paths_of.ts +5 -5
- package/transformers/flatteners/{flatten_type_def_to.ts → flatten_type_to.ts} +1 -1
- package/transformers/flatteners/{flatten_type_defs_of.ts → flatten_types_of_type.ts} +3 -3
- package/transformers/flatteners/flatten_validation_errors_of_type.ts +93 -0
- package/transformers/flatteners/flatten_validators_of_validating_type.ts +32 -0
- package/transformers/flatteners/{flatten_value_type_to.ts → flatten_value_to.ts} +12 -7
- package/transformers/flatteners/{flatten_value_types_of.ts → flatten_values_of_type.ts} +6 -6
- package/transformers/flatteners/specs/{flatten_accessors_of.tests.ts → flatten_accessors_of_type.tests.ts} +10 -11
- package/transformers/flatteners/specs/flatten_json_value_to_type_paths_of.tests.ts +6 -6
- package/transformers/flatteners/specs/{flatten_type_def_to.tests.ts → flatten_type_to.tests.ts} +15 -13
- package/transformers/flatteners/specs/flatten_types_of_type.tests.ts +27 -0
- package/transformers/flatteners/specs/flatten_validation_errors_of_type.tests.ts +48 -0
- package/transformers/flatteners/specs/{flatten_value_type_to.tests.ts → flatten_value_to.tests.ts} +124 -91
- package/transformers/flatteners/specs/{flatten_value_types_of.tests.ts → flatten_values_of_type.tests.ts} +4 -4
- package/transformers/flatteners/specs/value_path_to_type_path.tests.ts +20 -18
- package/transformers/flatteners/value_path_to_type_path.ts +4 -4
- package/types/builders.ts +239 -71
- package/types/definitions.ts +2 -2
- package/types/{flattened_accessors_of.ts → flattened_accessors_of_type.ts} +3 -3
- package/types/{flattened_type_defs_of.ts → flattened_types_of_type.ts} +22 -12
- package/types/flattened_types_of_validating_type.ts +152 -0
- package/types/flattened_validators_of_validating_type.ts +33 -0
- package/types/flattened_values_of_type.ts +11 -0
- package/types/{mobx_value_type_of.ts → mobx_value_of_type.ts} +2 -2
- package/types/{partial_type_def_of.ts → partial_type_of_type.ts} +3 -1
- package/types/{json_path_of.ts → path_of.ts} +1 -1
- package/types/{json_paths_of.ts → paths_of_type.ts} +5 -5
- package/types/readonly_type_of_type.ts +54 -0
- package/types/specs/builder.tests.ts +205 -54
- package/types/specs/{flattened_accessors_of.tests.ts → flattened_accessors_of_type.tests.ts} +3 -3
- package/types/specs/{flattened_type_defs_of.tests.ts → flattened_types_of_type.tests.ts} +82 -34
- package/types/specs/flattened_validators_of_validating_type.tests.ts +47 -0
- package/types/specs/flattened_values_of_type.tests.ts +39 -0
- package/types/specs/{partial_type_def_of.tests.ts → partial_type_of_type.tests.ts} +11 -11
- package/types/specs/{json_paths_of.tests.ts → paths_of_type.tests.ts} +47 -47
- package/types/specs/{readonly_type_def_of.tests.ts → readonly_type_of_type.tests.ts} +14 -14
- package/types/specs/type_of_type.tests.ts +60 -0
- package/types/specs/{value_type_of.tests.ts → value_of_type.tests.ts} +15 -15
- package/types/specs/{value_to_type_paths_of.tests.ts → value_to_type_paths_of_type.tests.ts} +26 -25
- package/types/specs/value_types_of_discriminated_union.tests.ts +6 -6
- package/types/strict_definitions.ts +3 -3
- package/types/type_of_type.ts +178 -0
- package/types/validating_definitions.ts +109 -0
- package/types/validating_type_def_with_error.ts +93 -0
- package/types/value_of_type.ts +84 -0
- package/types/{value_to_type_paths_of.ts → value_to_type_paths_of_type.ts} +30 -29
- package/types/value_types_of_discriminated_union.ts +4 -3
- package/validation/errors_of_validators.ts +10 -0
- package/validation/specs/errors_of_validators.tests.ts +20 -0
- package/validation/specs/validators_of_values.tests.ts +68 -0
- package/validation/validator.ts +103 -0
- package/validation/validators/defined_validator.ts +22 -0
- package/validation/validators/minimum_string_length_validator.ts +36 -0
- package/validation/validators_of_values.ts +17 -0
- package/.out/transformers/flatteners/flatten_accessors_of.d.ts +0 -5
- package/.out/transformers/flatteners/flatten_accessors_of.js +0 -11
- package/.out/transformers/flatteners/flatten_type_defs_of.js +0 -7
- package/.out/transformers/flatteners/flatten_value_types_of.d.ts +0 -3
- package/.out/transformers/flatteners/flatten_value_types_of.js +0 -7
- package/.out/transformers/flatteners/specs/flatten_type_defs_of.tests.js +0 -17
- package/.out/types/flattened_accessors_of.d.ts +0 -9
- package/.out/types/flattened_value_types_of.d.ts +0 -6
- package/.out/types/json_path_of.d.ts +0 -1
- package/.out/types/readonly_type_def_of.d.ts +0 -29
- package/.out/types/specs/flattened_value_types_of.tests.js +0 -11
- package/.out/types/value_type_of.d.ts +0 -24
- package/transformers/flatteners/specs/flatten_type_defs_of.tests.ts +0 -26
- package/types/flattened_value_types_of.ts +0 -11
- package/types/readonly_type_def_of.ts +0 -53
- package/types/specs/flattened_value_types_of.tests.ts +0 -21
- package/types/value_type_of.ts +0 -84
- /package/.out/transformers/flatteners/specs/{flatten_accessors_of.tests.d.ts → flatten_accessors_of_type.tests.d.ts} +0 -0
- /package/.out/transformers/flatteners/specs/{flatten_type_def_to.tests.d.ts → flatten_type_to.tests.d.ts} +0 -0
- /package/.out/transformers/flatteners/specs/{flatten_type_defs_of.tests.d.ts → flatten_types_of_type.tests.d.ts} +0 -0
- /package/.out/transformers/flatteners/specs/{flatten_value_type_to.tests.d.ts → flatten_validation_errors_of_type.tests.d.ts} +0 -0
- /package/.out/transformers/flatteners/specs/{flatten_value_types_of.tests.d.ts → flatten_value_to.tests.d.ts} +0 -0
- /package/.out/{types/flattened_accessors_of.js → transformers/flatteners/specs/flatten_values_of_type.tests.d.ts} +0 -0
- /package/.out/types/{flattened_type_defs_of.js → flattened_accessors_of_type.js} +0 -0
- /package/.out/types/{flattened_value_types_of.js → flattened_types_of_type.js} +0 -0
- /package/.out/types/{json_path_of.js → flattened_types_of_validating_type.js} +0 -0
- /package/.out/types/{json_paths_of.js → flattened_validators_of_validating_type.js} +0 -0
- /package/.out/types/{partial_type_def_of.js → flattened_values_of_type.js} +0 -0
- /package/.out/types/{mobx_value_type_of.js → mobx_value_of_type.js} +0 -0
- /package/.out/types/{readonly_type_def_of.js → partial_type_of_type.js} +0 -0
- /package/.out/types/{specs/flattened_accessors_of.tests.d.ts → path_of.js} +0 -0
- /package/.out/types/{specs/flattened_type_defs_of.tests.d.ts → paths_of_type.js} +0 -0
- /package/.out/types/{specs/flattened_value_types_of.tests.d.ts → readonly_type_of_type.js} +0 -0
- /package/.out/types/specs/{json_paths_of.tests.d.ts → flattened_accessors_of_type.tests.d.ts} +0 -0
- /package/.out/types/specs/{partial_type_def_of.tests.d.ts → flattened_types_of_type.tests.d.ts} +0 -0
- /package/.out/types/specs/{readonly_type_def_of.tests.d.ts → flattened_validators_of_validating_type.tests.d.ts} +0 -0
- /package/.out/types/specs/{value_to_type_paths_of.tests.d.ts → flattened_values_of_type.tests.d.ts} +0 -0
- /package/.out/types/specs/{value_type_of.tests.d.ts → partial_type_of_type.tests.d.ts} +0 -0
- /package/.out/types/{value_to_type_paths_of.js → specs/paths_of_type.tests.d.ts} +0 -0
- /package/.out/types/{value_type_of.js → specs/readonly_type_of_type.tests.d.ts} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Reverse } from '@strictly/base'
|
|
2
|
+
import {
|
|
3
|
+
list,
|
|
4
|
+
numberType,
|
|
5
|
+
} from 'types/builders'
|
|
6
|
+
import { type FlattenedValidatorsOfValidatingType } from 'types/flattened_validators_of_validating_type'
|
|
7
|
+
import { type ValueToTypePathsOfType } from 'types/value_to_type_paths_of_type'
|
|
8
|
+
import { type Validator } from 'validation/validator'
|
|
9
|
+
|
|
10
|
+
describe('FlattenedValidatorsOfValidatingType', function () {
|
|
11
|
+
describe('literal', function () {
|
|
12
|
+
const literalType = numberType.enforce(function (): 'a' {
|
|
13
|
+
return 'a'
|
|
14
|
+
})
|
|
15
|
+
type T = FlattenedValidatorsOfValidatingType<
|
|
16
|
+
typeof literalType,
|
|
17
|
+
Reverse<ValueToTypePathsOfType<typeof literalType>>
|
|
18
|
+
>
|
|
19
|
+
|
|
20
|
+
let t: {
|
|
21
|
+
readonly $: Validator<number, 'a', '$', number>,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
it('equals expected type', function () {
|
|
25
|
+
expectTypeOf<T>().toEqualTypeOf(t)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('list', function () {
|
|
30
|
+
const literalType = numberType.enforce(function (): 'x' {
|
|
31
|
+
return 'x'
|
|
32
|
+
})
|
|
33
|
+
const listType = list(literalType.narrow).enforce(function (): 'y' {
|
|
34
|
+
return 'y'
|
|
35
|
+
})
|
|
36
|
+
type T = FlattenedValidatorsOfValidatingType<typeof listType, Reverse<ValueToTypePathsOfType<typeof listType>>>
|
|
37
|
+
|
|
38
|
+
let t: {
|
|
39
|
+
readonly $: Validator<readonly number[], 'y', '$', readonly number[]>,
|
|
40
|
+
readonly '$.*': Validator<number, 'x', `$.${number}`, readonly number[]>,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
it('equals expected type', function () {
|
|
44
|
+
expectTypeOf<T>().toEqualTypeOf(t)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
numberType,
|
|
3
|
+
object,
|
|
4
|
+
record,
|
|
5
|
+
stringType,
|
|
6
|
+
} from 'types/builders'
|
|
7
|
+
import { type FlattenedValuesOfType } from 'types/flattened_values_of_type'
|
|
8
|
+
|
|
9
|
+
describe('FlattenedValuesOfType', function () {
|
|
10
|
+
// note we only test a small example since most of the work is done in flatten
|
|
11
|
+
describe('record', function () {
|
|
12
|
+
const builder = record<typeof numberType, string>(numberType)
|
|
13
|
+
type V = FlattenedValuesOfType<typeof builder.narrow>
|
|
14
|
+
|
|
15
|
+
let v: {
|
|
16
|
+
readonly $: Record<string, number>,
|
|
17
|
+
readonly [_: `$.${string}`]: number,
|
|
18
|
+
}
|
|
19
|
+
it('equals expected type', function () {
|
|
20
|
+
expectTypeOf(v).toEqualTypeOf<V>()
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('object', function () {
|
|
25
|
+
const builder = object().optionalField('a', stringType)
|
|
26
|
+
type V = FlattenedValuesOfType<typeof builder>
|
|
27
|
+
|
|
28
|
+
let v: {
|
|
29
|
+
readonly $: {
|
|
30
|
+
a?: string | undefined,
|
|
31
|
+
},
|
|
32
|
+
readonly '$.a': string | undefined,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
it('equals expected type', function () {
|
|
36
|
+
expectTypeOf(v).toEqualTypeOf<V>()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
union,
|
|
9
9
|
} from 'types/builders'
|
|
10
10
|
import { type TypeDefType } from 'types/definitions'
|
|
11
|
-
import { type
|
|
11
|
+
import { type PartialTypeOfType } from 'types/partial_type_of_type'
|
|
12
12
|
|
|
13
13
|
describe('PartialTypeDefOf', function () {
|
|
14
14
|
describe('literal', function () {
|
|
15
|
-
type T =
|
|
15
|
+
type T = PartialTypeOfType<typeof numberType._type>
|
|
16
16
|
|
|
17
17
|
let t: {
|
|
18
18
|
readonly typeDef: {
|
|
@@ -38,7 +38,7 @@ describe('PartialTypeDefOf', function () {
|
|
|
38
38
|
|
|
39
39
|
describe('list', function () {
|
|
40
40
|
const builder = list(numberType)
|
|
41
|
-
type T =
|
|
41
|
+
type T = PartialTypeOfType<typeof builder._type>
|
|
42
42
|
|
|
43
43
|
let t: {
|
|
44
44
|
readonly typeDef: {
|
|
@@ -76,7 +76,7 @@ describe('PartialTypeDefOf', function () {
|
|
|
76
76
|
|
|
77
77
|
describe('record', function () {
|
|
78
78
|
const builder = record<typeof numberType, 'a' | 'b'>(numberType)
|
|
79
|
-
type T = SimplifyDeep<
|
|
79
|
+
type T = SimplifyDeep<PartialTypeOfType<typeof builder._type>>
|
|
80
80
|
|
|
81
81
|
let t: {
|
|
82
82
|
readonly typeDef: {
|
|
@@ -116,9 +116,9 @@ describe('PartialTypeDefOf', function () {
|
|
|
116
116
|
|
|
117
117
|
describe('object', function () {
|
|
118
118
|
const builder = object()
|
|
119
|
-
.
|
|
120
|
-
.
|
|
121
|
-
type T =
|
|
119
|
+
.field('a', numberType)
|
|
120
|
+
.readonlyField('b', stringType)
|
|
121
|
+
type T = PartialTypeOfType<typeof builder._type>
|
|
122
122
|
|
|
123
123
|
let t: {
|
|
124
124
|
readonly typeDef: {
|
|
@@ -174,9 +174,9 @@ describe('PartialTypeDefOf', function () {
|
|
|
174
174
|
describe('union', function () {
|
|
175
175
|
describe('simple', function () {
|
|
176
176
|
const builder = union()
|
|
177
|
-
.
|
|
178
|
-
.
|
|
179
|
-
type T =
|
|
177
|
+
.or('1', numberType)
|
|
178
|
+
.or('2', stringType)
|
|
179
|
+
type T = PartialTypeOfType<typeof builder._type>
|
|
180
180
|
|
|
181
181
|
let t: {
|
|
182
182
|
readonly typeDef: {
|
|
@@ -213,7 +213,7 @@ describe('PartialTypeDefOf', function () {
|
|
|
213
213
|
|
|
214
214
|
describe('readonly', function () {
|
|
215
215
|
const builder = list(numberType).readonly()
|
|
216
|
-
type T =
|
|
216
|
+
type T = PartialTypeOfType<typeof builder._type>
|
|
217
217
|
|
|
218
218
|
let t: {
|
|
219
219
|
readonly typeDef: {
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
stringType,
|
|
9
9
|
union,
|
|
10
10
|
} from 'types/builders'
|
|
11
|
-
import { type
|
|
11
|
+
import { type PathsOfType } from 'types/paths_of_type'
|
|
12
12
|
|
|
13
|
-
describe('
|
|
13
|
+
describe('PathsOfType', function () {
|
|
14
14
|
describe('literal', function () {
|
|
15
15
|
let path: '$'
|
|
16
16
|
|
|
17
17
|
describe('regular', function () {
|
|
18
|
-
type T =
|
|
18
|
+
type T = PathsOfType<typeof stringType>
|
|
19
19
|
|
|
20
20
|
it('equals expected type', function () {
|
|
21
21
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -24,7 +24,7 @@ describe('JsonPathsOf', function () {
|
|
|
24
24
|
|
|
25
25
|
describe('nullable', function () {
|
|
26
26
|
const builder = nullable(stringType)
|
|
27
|
-
type T =
|
|
27
|
+
type T = PathsOfType<typeof builder>
|
|
28
28
|
|
|
29
29
|
it('equals expected type', function () {
|
|
30
30
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -37,7 +37,7 @@ describe('JsonPathsOf', function () {
|
|
|
37
37
|
|
|
38
38
|
describe('mutable', function () {
|
|
39
39
|
const builder = list(stringType)
|
|
40
|
-
type T =
|
|
40
|
+
type T = PathsOfType<typeof builder>
|
|
41
41
|
|
|
42
42
|
it('equals expected type', function () {
|
|
43
43
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -46,7 +46,7 @@ describe('JsonPathsOf', function () {
|
|
|
46
46
|
|
|
47
47
|
describe('readonly', function () {
|
|
48
48
|
const builder = list(stringType).readonly()
|
|
49
|
-
type T =
|
|
49
|
+
type T = PathsOfType<typeof builder>
|
|
50
50
|
|
|
51
51
|
it('equals expected type', function () {
|
|
52
52
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -55,7 +55,7 @@ describe('JsonPathsOf', function () {
|
|
|
55
55
|
|
|
56
56
|
describe('nullable', function () {
|
|
57
57
|
const builder = nullable(list(stringType))
|
|
58
|
-
type T =
|
|
58
|
+
type T = PathsOfType<typeof builder>
|
|
59
59
|
|
|
60
60
|
it('equals expected type', function () {
|
|
61
61
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -64,7 +64,7 @@ describe('JsonPathsOf', function () {
|
|
|
64
64
|
|
|
65
65
|
describe('override', function () {
|
|
66
66
|
const builder = list(stringType)
|
|
67
|
-
type T =
|
|
67
|
+
type T = PathsOfType<typeof builder, 'o'>
|
|
68
68
|
|
|
69
69
|
let path: '$' | `$.o`
|
|
70
70
|
it('equals expected type', function () {
|
|
@@ -78,7 +78,7 @@ describe('JsonPathsOf', function () {
|
|
|
78
78
|
|
|
79
79
|
describe('mutable', function () {
|
|
80
80
|
const builder = record(stringType)
|
|
81
|
-
type T =
|
|
81
|
+
type T = PathsOfType<typeof builder>
|
|
82
82
|
|
|
83
83
|
it('equals expected type', function () {
|
|
84
84
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -87,7 +87,7 @@ describe('JsonPathsOf', function () {
|
|
|
87
87
|
|
|
88
88
|
describe('mutable with exact keys', function () {
|
|
89
89
|
const builder = record<typeof stringType, 'a' | 'b'>(stringType)
|
|
90
|
-
type T =
|
|
90
|
+
type T = PathsOfType<typeof builder>
|
|
91
91
|
|
|
92
92
|
let path: '$' | '$.a' | '$.b'
|
|
93
93
|
it('equals expected type', function () {
|
|
@@ -97,7 +97,7 @@ describe('JsonPathsOf', function () {
|
|
|
97
97
|
|
|
98
98
|
describe('mutable with numeric keys', function () {
|
|
99
99
|
const builder = record<typeof stringType, 1 | 2 | 3>(stringType)
|
|
100
|
-
type T =
|
|
100
|
+
type T = PathsOfType<typeof builder>
|
|
101
101
|
|
|
102
102
|
let path: '$' | '$.1' | '$.2' | '$.3'
|
|
103
103
|
it('equals expected type', function () {
|
|
@@ -107,7 +107,7 @@ describe('JsonPathsOf', function () {
|
|
|
107
107
|
|
|
108
108
|
describe('readonly', function () {
|
|
109
109
|
const builder = record(stringType).readonly()
|
|
110
|
-
type T =
|
|
110
|
+
type T = PathsOfType<typeof builder>
|
|
111
111
|
|
|
112
112
|
it('equals expected type', function () {
|
|
113
113
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -115,8 +115,8 @@ describe('JsonPathsOf', function () {
|
|
|
115
115
|
})
|
|
116
116
|
|
|
117
117
|
describe('partial', function () {
|
|
118
|
-
const builder = record(stringType).
|
|
119
|
-
type T =
|
|
118
|
+
const builder = record(stringType).partialKeys()
|
|
119
|
+
type T = PathsOfType<typeof builder>
|
|
120
120
|
|
|
121
121
|
it('equals expected type', function () {
|
|
122
122
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -125,7 +125,7 @@ describe('JsonPathsOf', function () {
|
|
|
125
125
|
|
|
126
126
|
describe('nullable', function () {
|
|
127
127
|
const builder = nullable(record(stringType))
|
|
128
|
-
type T =
|
|
128
|
+
type T = PathsOfType<typeof builder>
|
|
129
129
|
|
|
130
130
|
it('equals expected type', function () {
|
|
131
131
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
@@ -134,7 +134,7 @@ describe('JsonPathsOf', function () {
|
|
|
134
134
|
|
|
135
135
|
describe('override', function () {
|
|
136
136
|
const builder = record(stringType)
|
|
137
|
-
type T =
|
|
137
|
+
type T = PathsOfType<typeof builder, 'x'>
|
|
138
138
|
|
|
139
139
|
let path: '$' | '$.x'
|
|
140
140
|
it('equals expected type', function () {
|
|
@@ -146,10 +146,10 @@ describe('JsonPathsOf', function () {
|
|
|
146
146
|
describe('object', function () {
|
|
147
147
|
describe('simple', function () {
|
|
148
148
|
const builder = object()
|
|
149
|
-
.
|
|
150
|
-
.
|
|
151
|
-
.
|
|
152
|
-
type T =
|
|
149
|
+
.field('n', numberType)
|
|
150
|
+
.field('b', booleanType)
|
|
151
|
+
.field('s', stringType)
|
|
152
|
+
type T = PathsOfType<typeof builder>
|
|
153
153
|
|
|
154
154
|
let path: '$' | '$.n' | '$.b' | '$.s'
|
|
155
155
|
it('equals expected type', function () {
|
|
@@ -170,16 +170,16 @@ describe('JsonPathsOf', function () {
|
|
|
170
170
|
})
|
|
171
171
|
|
|
172
172
|
it('ignores override', function () {
|
|
173
|
-
type T =
|
|
173
|
+
type T = PathsOfType<typeof builder, 'y'>
|
|
174
174
|
expectTypeOf(path).toEqualTypeOf<T>()
|
|
175
175
|
})
|
|
176
176
|
})
|
|
177
177
|
|
|
178
178
|
describe('nested', function () {
|
|
179
179
|
const builder = object()
|
|
180
|
-
.
|
|
181
|
-
.
|
|
182
|
-
type T =
|
|
180
|
+
.field('s1', object().field('a1', booleanType))
|
|
181
|
+
.field('s2', object().field('a2', stringType))
|
|
182
|
+
type T = PathsOfType<typeof builder>
|
|
183
183
|
|
|
184
184
|
let path: '$' | '$.s1' | '$.s1.a1' | '$.s2' | '$.s2.a2'
|
|
185
185
|
it('equals expected type', function () {
|
|
@@ -189,10 +189,10 @@ describe('JsonPathsOf', function () {
|
|
|
189
189
|
|
|
190
190
|
describe('object of list', function () {
|
|
191
191
|
const builder = object()
|
|
192
|
-
.
|
|
192
|
+
.field('l', list(numberType))
|
|
193
193
|
|
|
194
194
|
describe('no override', function () {
|
|
195
|
-
type T =
|
|
195
|
+
type T = PathsOfType<typeof builder>
|
|
196
196
|
|
|
197
197
|
let path: '$' | '$.l' | `$.l.${number}`
|
|
198
198
|
it('equals expected type', function () {
|
|
@@ -201,7 +201,7 @@ describe('JsonPathsOf', function () {
|
|
|
201
201
|
})
|
|
202
202
|
|
|
203
203
|
describe('passes override', function () {
|
|
204
|
-
type T =
|
|
204
|
+
type T = PathsOfType<typeof builder, 'o'>
|
|
205
205
|
|
|
206
206
|
let path: '$' | '$.l' | '$.l.o'
|
|
207
207
|
it('equals expected type', function () {
|
|
@@ -214,9 +214,9 @@ describe('JsonPathsOf', function () {
|
|
|
214
214
|
describe('union', function () {
|
|
215
215
|
describe('with primitives', function () {
|
|
216
216
|
const builder = union()
|
|
217
|
-
.
|
|
218
|
-
.
|
|
219
|
-
type T =
|
|
217
|
+
.or('1', numberType)
|
|
218
|
+
.or('2', stringType)
|
|
219
|
+
type T = PathsOfType<typeof builder>
|
|
220
220
|
|
|
221
221
|
let path: '$'
|
|
222
222
|
it('equals expected type', function () {
|
|
@@ -226,10 +226,10 @@ describe('JsonPathsOf', function () {
|
|
|
226
226
|
|
|
227
227
|
describe('with overlapping record', function () {
|
|
228
228
|
const builder = union()
|
|
229
|
-
.
|
|
230
|
-
.
|
|
231
|
-
.
|
|
232
|
-
type T =
|
|
229
|
+
.or('1', object().field('a', numberType).field('b', stringType))
|
|
230
|
+
.or('2', object().field('b', stringType).field('c', stringType))
|
|
231
|
+
.or('3', object().field('c', stringType).field('a', stringType))
|
|
232
|
+
type T = PathsOfType<typeof builder>
|
|
233
233
|
|
|
234
234
|
let path: '$' | '$.a' | '$.b' | '$.c'
|
|
235
235
|
it('equals expected type', function () {
|
|
@@ -239,15 +239,15 @@ describe('JsonPathsOf', function () {
|
|
|
239
239
|
|
|
240
240
|
describe('nested', function () {
|
|
241
241
|
const builder = union()
|
|
242
|
-
.
|
|
242
|
+
.or('1', object().field(
|
|
243
243
|
'a',
|
|
244
|
-
union().
|
|
244
|
+
union().or('x', object().field('aa', stringType)),
|
|
245
245
|
))
|
|
246
|
-
.
|
|
246
|
+
.or('2', object().field(
|
|
247
247
|
'b',
|
|
248
|
-
union().
|
|
248
|
+
union().or('y', object().field('bb', stringType)),
|
|
249
249
|
))
|
|
250
|
-
type T =
|
|
250
|
+
type T = PathsOfType<typeof builder>
|
|
251
251
|
|
|
252
252
|
let path: '$' | '$.a' | '$.a.aa' | '$.b' | '$.b.bb'
|
|
253
253
|
it('equals expected type', function () {
|
|
@@ -258,10 +258,10 @@ describe('JsonPathsOf', function () {
|
|
|
258
258
|
|
|
259
259
|
describe('with discriminator', function () {
|
|
260
260
|
const builder = union('x')
|
|
261
|
-
.
|
|
262
|
-
.
|
|
261
|
+
.or('1', object().field('a', booleanType))
|
|
262
|
+
.or('2', object().field('b', numberType))
|
|
263
263
|
|
|
264
|
-
type T =
|
|
264
|
+
type T = PathsOfType<typeof builder>
|
|
265
265
|
|
|
266
266
|
let path: '$' | '$.1:a' | '$.2:b'
|
|
267
267
|
|
|
@@ -272,16 +272,16 @@ describe('JsonPathsOf', function () {
|
|
|
272
272
|
|
|
273
273
|
describe('with nested discriminator', function () {
|
|
274
274
|
const builder = union('x')
|
|
275
|
-
.
|
|
275
|
+
.or(
|
|
276
276
|
'1',
|
|
277
|
-
union('y').
|
|
277
|
+
union('y').or('p', object().field('a', booleanType)),
|
|
278
278
|
)
|
|
279
|
-
.
|
|
279
|
+
.or(
|
|
280
280
|
'2',
|
|
281
|
-
union('z').
|
|
281
|
+
union('z').or('q', object().field('b', numberType)),
|
|
282
282
|
)
|
|
283
283
|
|
|
284
|
-
type T =
|
|
284
|
+
type T = PathsOfType<typeof builder>
|
|
285
285
|
|
|
286
286
|
let path: '$' | '$.1:p:a' | '$.2:q:b'
|
|
287
287
|
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
union,
|
|
8
8
|
} from 'types/builders'
|
|
9
9
|
import { type TypeDefType } from 'types/definitions'
|
|
10
|
-
import { type
|
|
10
|
+
import { type ReadonlyTypeOfType } from 'types/readonly_type_of_type'
|
|
11
11
|
|
|
12
12
|
describe('ReadonlyTypeDefOf', function () {
|
|
13
13
|
describe('literal', function () {
|
|
14
|
-
type T =
|
|
14
|
+
type T = ReadonlyTypeOfType<typeof numberType._type>
|
|
15
15
|
|
|
16
16
|
let t: {
|
|
17
17
|
readonly definition: {
|
|
@@ -26,7 +26,7 @@ describe('ReadonlyTypeDefOf', function () {
|
|
|
26
26
|
|
|
27
27
|
describe('list', function () {
|
|
28
28
|
const builder = list(numberType)
|
|
29
|
-
type T =
|
|
29
|
+
type T = ReadonlyTypeOfType<typeof builder._type>
|
|
30
30
|
|
|
31
31
|
let t: {
|
|
32
32
|
readonly definition: {
|
|
@@ -44,7 +44,7 @@ describe('ReadonlyTypeDefOf', function () {
|
|
|
44
44
|
|
|
45
45
|
describe('record', function () {
|
|
46
46
|
const builder = record<typeof numberType, 'a' | 'b'>(numberType)
|
|
47
|
-
type T =
|
|
47
|
+
type T = ReadonlyTypeOfType<typeof builder._type>
|
|
48
48
|
|
|
49
49
|
let t: {
|
|
50
50
|
readonly definition: {
|
|
@@ -63,9 +63,9 @@ describe('ReadonlyTypeDefOf', function () {
|
|
|
63
63
|
|
|
64
64
|
describe('object', function () {
|
|
65
65
|
const builder = object()
|
|
66
|
-
.
|
|
67
|
-
.
|
|
68
|
-
type T =
|
|
66
|
+
.field('a', numberType)
|
|
67
|
+
.optionalField('b', stringType)
|
|
68
|
+
type T = ReadonlyTypeOfType<typeof builder._type>
|
|
69
69
|
|
|
70
70
|
let t: {
|
|
71
71
|
readonly definition: {
|
|
@@ -89,9 +89,9 @@ describe('ReadonlyTypeDefOf', function () {
|
|
|
89
89
|
|
|
90
90
|
describe('union', function () {
|
|
91
91
|
const builder = union()
|
|
92
|
-
.
|
|
93
|
-
.
|
|
94
|
-
type T =
|
|
92
|
+
.or('1', record<typeof numberType, 'a'>(numberType))
|
|
93
|
+
.or('2', stringType)
|
|
94
|
+
type T = ReadonlyTypeOfType<typeof builder._type>
|
|
95
95
|
|
|
96
96
|
let t: {
|
|
97
97
|
readonly definition: {
|
|
@@ -119,8 +119,8 @@ describe('ReadonlyTypeDefOf', function () {
|
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
describe('partial', function () {
|
|
122
|
-
const builder = record<typeof numberType, 'a'>(numberType).
|
|
123
|
-
type T =
|
|
122
|
+
const builder = record<typeof numberType, 'a'>(numberType).partialKeys()
|
|
123
|
+
type T = ReadonlyTypeOfType<typeof builder._type>
|
|
124
124
|
|
|
125
125
|
let t: {
|
|
126
126
|
readonly definition: {
|
|
@@ -138,8 +138,8 @@ describe('ReadonlyTypeDefOf', function () {
|
|
|
138
138
|
})
|
|
139
139
|
|
|
140
140
|
describe('readonly', function () {
|
|
141
|
-
const builder = record<typeof numberType, 'a'>(numberType).
|
|
142
|
-
type T =
|
|
141
|
+
const builder = record<typeof numberType, 'a'>(numberType).readonlyKeys()
|
|
142
|
+
type T = ReadonlyTypeOfType<typeof builder._type>
|
|
143
143
|
|
|
144
144
|
let t: {
|
|
145
145
|
readonly definition: {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
list,
|
|
3
|
+
numberType,
|
|
4
|
+
} from 'types/builders'
|
|
5
|
+
import { type TypeDefType } from 'types/definitions'
|
|
6
|
+
import { type TypeOfType } from 'types/type_of_type'
|
|
7
|
+
|
|
8
|
+
describe('TypeOfType', function () {
|
|
9
|
+
describe('literal', function () {
|
|
10
|
+
const literalType = numberType
|
|
11
|
+
type T = TypeOfType<typeof literalType>
|
|
12
|
+
let t: {
|
|
13
|
+
readonly definition: {
|
|
14
|
+
readonly type: TypeDefType.Literal,
|
|
15
|
+
readonly valuePrototype: [number],
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
it('equals expected type', function () {
|
|
20
|
+
expectTypeOf<T>().toEqualTypeOf(t)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('list', function () {
|
|
25
|
+
describe('mutable', function () {
|
|
26
|
+
const listType = list(numberType)
|
|
27
|
+
type T = TypeOfType<typeof listType>
|
|
28
|
+
let t: {
|
|
29
|
+
readonly definition: {
|
|
30
|
+
readonly type: TypeDefType.List,
|
|
31
|
+
elements: {
|
|
32
|
+
readonly type: TypeDefType.Literal,
|
|
33
|
+
readonly valuePrototype: [number],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
it('equals expected type', function () {
|
|
38
|
+
expectTypeOf<T>().toEqualTypeOf(t)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
describe('readonly', function () {
|
|
42
|
+
const listType = list(numberType).readonlyElements()
|
|
43
|
+
type T = TypeOfType<typeof listType>
|
|
44
|
+
let t: {
|
|
45
|
+
readonly definition: {
|
|
46
|
+
readonly type: TypeDefType.List,
|
|
47
|
+
readonly elements: {
|
|
48
|
+
readonly type: TypeDefType.Literal,
|
|
49
|
+
readonly valuePrototype: [number],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
it('equals expected type', function () {
|
|
54
|
+
expectTypeOf<T>().toEqualTypeOf(t)
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// TODO other types
|
|
60
|
+
})
|
|
@@ -2,15 +2,15 @@ import { type SimplifyDeep } from 'type-fest'
|
|
|
2
2
|
import {
|
|
3
3
|
type TypeDefType,
|
|
4
4
|
} from 'types/definitions'
|
|
5
|
-
import { type
|
|
5
|
+
import { type ValueOfType } from 'types/value_of_type'
|
|
6
6
|
|
|
7
|
-
describe('
|
|
7
|
+
describe('ValueOfType', function () {
|
|
8
8
|
describe('literal', function () {
|
|
9
9
|
type TypeD = {
|
|
10
10
|
readonly type: TypeDefType.Literal,
|
|
11
11
|
readonly valuePrototype: ['a' | 'b' | 'c'],
|
|
12
12
|
}
|
|
13
|
-
type T =
|
|
13
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
14
14
|
|
|
15
15
|
let t: 'a' | 'b' | 'c'
|
|
16
16
|
it('equals expected type', function () {
|
|
@@ -27,7 +27,7 @@ describe('ValueTypeOf', function () {
|
|
|
27
27
|
readonly valuePrototype: ['a' | 'b' | 'c'],
|
|
28
28
|
},
|
|
29
29
|
}
|
|
30
|
-
type T =
|
|
30
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
31
31
|
describe('mutable', function () {
|
|
32
32
|
let a: ('a' | 'b' | 'c')[]
|
|
33
33
|
it('equals expected type', function () {
|
|
@@ -36,7 +36,7 @@ describe('ValueTypeOf', function () {
|
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
describe('readonly', function () {
|
|
39
|
-
type R =
|
|
39
|
+
type R = ValueOfType<{
|
|
40
40
|
definition: {
|
|
41
41
|
readonly type: TypeDefType.List,
|
|
42
42
|
readonly elements: {
|
|
@@ -63,7 +63,7 @@ describe('ValueTypeOf', function () {
|
|
|
63
63
|
readonly valuePrototype: ['a' | 'b' | 'c'],
|
|
64
64
|
},
|
|
65
65
|
}
|
|
66
|
-
type T =
|
|
66
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
67
67
|
|
|
68
68
|
describe('mutable', function () {
|
|
69
69
|
let t: Record<'x' | 'y' | 'z', 'a' | 'b' | 'c'>
|
|
@@ -73,7 +73,7 @@ describe('ValueTypeOf', function () {
|
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
describe('readonly', function () {
|
|
76
|
-
type R =
|
|
76
|
+
type R = ValueOfType<{
|
|
77
77
|
readonly definition: {
|
|
78
78
|
readonly type: TypeDefType.Record,
|
|
79
79
|
readonly keyPrototype: 'x' | 'y' | 'z',
|
|
@@ -99,7 +99,7 @@ describe('ValueTypeOf', function () {
|
|
|
99
99
|
readonly valuePrototype: ['a' | 'b' | 'c'],
|
|
100
100
|
} | undefined,
|
|
101
101
|
}
|
|
102
|
-
type T =
|
|
102
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
103
103
|
|
|
104
104
|
let t: Partial<Record<'x' | 'y' | 'z', 'a' | 'b' | 'c'>>
|
|
105
105
|
it('equals expected type', function () {
|
|
@@ -116,7 +116,7 @@ describe('ValueTypeOf', function () {
|
|
|
116
116
|
readonly valuePrototype: ['a' | 'b' | 'c'],
|
|
117
117
|
} | undefined,
|
|
118
118
|
}
|
|
119
|
-
type T =
|
|
119
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
120
120
|
|
|
121
121
|
let t: Partial<Readonly<Record<'x' | 'y' | 'z', 'a' | 'b' | 'c'>>>
|
|
122
122
|
it('equals expected type', function () {
|
|
@@ -139,7 +139,7 @@ describe('ValueTypeOf', function () {
|
|
|
139
139
|
},
|
|
140
140
|
},
|
|
141
141
|
}
|
|
142
|
-
type T =
|
|
142
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
143
143
|
|
|
144
144
|
describe('mutable', function () {
|
|
145
145
|
let value: {
|
|
@@ -166,7 +166,7 @@ describe('ValueTypeOf', function () {
|
|
|
166
166
|
},
|
|
167
167
|
},
|
|
168
168
|
}
|
|
169
|
-
type T =
|
|
169
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
170
170
|
|
|
171
171
|
let value: {
|
|
172
172
|
readonly a: 'a' | 'b',
|
|
@@ -191,7 +191,7 @@ describe('ValueTypeOf', function () {
|
|
|
191
191
|
},
|
|
192
192
|
},
|
|
193
193
|
}
|
|
194
|
-
type T =
|
|
194
|
+
type T = ValueOfType<{ definition: TypeD }>
|
|
195
195
|
|
|
196
196
|
let v: {
|
|
197
197
|
a?: 'a' | 'b',
|
|
@@ -206,7 +206,7 @@ describe('ValueTypeOf', function () {
|
|
|
206
206
|
|
|
207
207
|
describe('union', function () {
|
|
208
208
|
describe('non-discriminated', function () {
|
|
209
|
-
type T =
|
|
209
|
+
type T = ValueOfType<{
|
|
210
210
|
definition: {
|
|
211
211
|
readonly type: TypeDefType.Union,
|
|
212
212
|
readonly discriminator: null,
|
|
@@ -235,7 +235,7 @@ describe('ValueTypeOf', function () {
|
|
|
235
235
|
})
|
|
236
236
|
|
|
237
237
|
describe('implicitly discriminated', function () {
|
|
238
|
-
type T =
|
|
238
|
+
type T = ValueOfType<{
|
|
239
239
|
definition: {
|
|
240
240
|
readonly type: TypeDefType.Union,
|
|
241
241
|
readonly discriminator: null,
|
|
@@ -285,7 +285,7 @@ describe('ValueTypeOf', function () {
|
|
|
285
285
|
|
|
286
286
|
describe('explicitly discriminated', function () {
|
|
287
287
|
type T = SimplifyDeep<
|
|
288
|
-
|
|
288
|
+
ValueOfType<{
|
|
289
289
|
definition: {
|
|
290
290
|
readonly type: TypeDefType.Union,
|
|
291
291
|
readonly discriminator: 'd',
|