@strictly/define 0.0.1

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.
Files changed (162) hide show
  1. package/.eslintrc.cjs +31 -0
  2. package/.out/index.d.ts +20 -0
  3. package/.out/index.js +20 -0
  4. package/.out/transformers/copies/copy.d.ts +4 -0
  5. package/.out/transformers/copies/copy.js +7 -0
  6. package/.out/transformers/copies/copy_to.d.ts +6 -0
  7. package/.out/transformers/copies/copy_to.js +91 -0
  8. package/.out/transformers/copies/mobx_copy.d.ts +5 -0
  9. package/.out/transformers/copies/mobx_copy.js +42 -0
  10. package/.out/transformers/copies/specs/copy_to.tests.d.ts +1 -0
  11. package/.out/transformers/copies/specs/copy_to.tests.js +97 -0
  12. package/.out/transformers/copies/specs/mobx_copy.tests.d.ts +1 -0
  13. package/.out/transformers/copies/specs/mobx_copy.tests.js +19 -0
  14. package/.out/transformers/flatteners/flatten_accessors_of.d.ts +5 -0
  15. package/.out/transformers/flatteners/flatten_accessors_of.js +11 -0
  16. package/.out/transformers/flatteners/flatten_json_value_to_type_paths_of.d.ts +3 -0
  17. package/.out/transformers/flatteners/flatten_json_value_to_type_paths_of.js +10 -0
  18. package/.out/transformers/flatteners/flatten_type_def_to.d.ts +4 -0
  19. package/.out/transformers/flatteners/flatten_type_def_to.js +49 -0
  20. package/.out/transformers/flatteners/flatten_type_defs_of.d.ts +3 -0
  21. package/.out/transformers/flatteners/flatten_type_defs_of.js +7 -0
  22. package/.out/transformers/flatteners/flatten_value_type_to.d.ts +11 -0
  23. package/.out/transformers/flatteners/flatten_value_type_to.js +79 -0
  24. package/.out/transformers/flatteners/flatten_value_types_of.d.ts +3 -0
  25. package/.out/transformers/flatteners/flatten_value_types_of.js +7 -0
  26. package/.out/transformers/flatteners/json_path.d.ts +2 -0
  27. package/.out/transformers/flatteners/json_path.js +14 -0
  28. package/.out/transformers/flatteners/specs/flatten_accessors_of.tests.d.ts +1 -0
  29. package/.out/transformers/flatteners/specs/flatten_accessors_of.tests.js +90 -0
  30. package/.out/transformers/flatteners/specs/flatten_json_value_to_type_paths_of.tests.d.ts +1 -0
  31. package/.out/transformers/flatteners/specs/flatten_json_value_to_type_paths_of.tests.js +94 -0
  32. package/.out/transformers/flatteners/specs/flatten_type_def_to.tests.d.ts +1 -0
  33. package/.out/transformers/flatteners/specs/flatten_type_def_to.tests.js +110 -0
  34. package/.out/transformers/flatteners/specs/flatten_type_defs_of.tests.d.ts +1 -0
  35. package/.out/transformers/flatteners/specs/flatten_type_defs_of.tests.js +17 -0
  36. package/.out/transformers/flatteners/specs/flatten_value_type_to.tests.d.ts +1 -0
  37. package/.out/transformers/flatteners/specs/flatten_value_type_to.tests.js +297 -0
  38. package/.out/transformers/flatteners/specs/flatten_value_types_of.tests.d.ts +1 -0
  39. package/.out/transformers/flatteners/specs/flatten_value_types_of.tests.js +37 -0
  40. package/.out/transformers/flatteners/specs/value_path_to_type_path.tests.d.ts +1 -0
  41. package/.out/transformers/flatteners/specs/value_path_to_type_path.tests.js +167 -0
  42. package/.out/transformers/flatteners/value_path_to_type_path.d.ts +2 -0
  43. package/.out/transformers/flatteners/value_path_to_type_path.js +96 -0
  44. package/.out/tsconfig.json +15 -0
  45. package/.out/tsconfig.tsbuildinfo +1 -0
  46. package/.out/tsup.config.d.ts +3 -0
  47. package/.out/tsup.config.js +12 -0
  48. package/.out/types/builders.d.ts +62 -0
  49. package/.out/types/builders.js +148 -0
  50. package/.out/types/definitions.d.ts +41 -0
  51. package/.out/types/definitions.js +26 -0
  52. package/.out/types/flattened.d.ts +2 -0
  53. package/.out/types/flattened.js +1 -0
  54. package/.out/types/flattened_accessors_of.d.ts +9 -0
  55. package/.out/types/flattened_accessors_of.js +1 -0
  56. package/.out/types/flattened_type_defs_of.d.ts +21 -0
  57. package/.out/types/flattened_type_defs_of.js +1 -0
  58. package/.out/types/flattened_value_types_of.d.ts +6 -0
  59. package/.out/types/flattened_value_types_of.js +1 -0
  60. package/.out/types/json_path_of.d.ts +1 -0
  61. package/.out/types/json_path_of.js +1 -0
  62. package/.out/types/json_paths_of.d.ts +16 -0
  63. package/.out/types/json_paths_of.js +1 -0
  64. package/.out/types/mobx_value_type_of.d.ts +11 -0
  65. package/.out/types/mobx_value_type_of.js +2 -0
  66. package/.out/types/partial_type_def_of.d.ts +40 -0
  67. package/.out/types/partial_type_def_of.js +1 -0
  68. package/.out/types/readonly_type_def_of.d.ts +29 -0
  69. package/.out/types/readonly_type_def_of.js +1 -0
  70. package/.out/types/specs/builder.tests.d.ts +1 -0
  71. package/.out/types/specs/builder.tests.js +93 -0
  72. package/.out/types/specs/flattened_accessors_of.tests.d.ts +1 -0
  73. package/.out/types/specs/flattened_accessors_of.tests.js +11 -0
  74. package/.out/types/specs/flattened_type_defs_of.tests.d.ts +1 -0
  75. package/.out/types/specs/flattened_type_defs_of.tests.js +71 -0
  76. package/.out/types/specs/flattened_value_types_of.tests.d.ts +1 -0
  77. package/.out/types/specs/flattened_value_types_of.tests.js +11 -0
  78. package/.out/types/specs/json_paths_of.tests.d.ts +1 -0
  79. package/.out/types/specs/json_paths_of.tests.js +199 -0
  80. package/.out/types/specs/partial_type_def_of.tests.d.ts +1 -0
  81. package/.out/types/specs/partial_type_def_of.tests.js +50 -0
  82. package/.out/types/specs/readonly_type_def_of.tests.d.ts +1 -0
  83. package/.out/types/specs/readonly_type_def_of.tests.js +55 -0
  84. package/.out/types/specs/strict_definitions.tests.d.ts +1 -0
  85. package/.out/types/specs/strict_definitions.tests.js +42 -0
  86. package/.out/types/specs/value_to_type_paths_of.tests.d.ts +1 -0
  87. package/.out/types/specs/value_to_type_paths_of.tests.js +90 -0
  88. package/.out/types/specs/value_type_of.tests.d.ts +1 -0
  89. package/.out/types/specs/value_type_of.tests.js +91 -0
  90. package/.out/types/specs/value_types_of_discriminated_union.tests.d.ts +1 -0
  91. package/.out/types/specs/value_types_of_discriminated_union.tests.js +9 -0
  92. package/.out/types/strict_definitions.d.ts +44 -0
  93. package/.out/types/strict_definitions.js +1 -0
  94. package/.out/types/value_to_type_paths_of.d.ts +22 -0
  95. package/.out/types/value_to_type_paths_of.js +1 -0
  96. package/.out/types/value_type_of.d.ts +24 -0
  97. package/.out/types/value_type_of.js +1 -0
  98. package/.out/types/value_types_of_discriminated_union.d.ts +9 -0
  99. package/.out/types/value_types_of_discriminated_union.js +1 -0
  100. package/.out/vitest.workspace.d.ts +2 -0
  101. package/.out/vitest.workspace.js +7 -0
  102. package/.turbo/turbo-build.log +18 -0
  103. package/.turbo/turbo-check-types.log +3 -0
  104. package/.turbo/turbo-release$colon$exports.log +3 -0
  105. package/README.md +12 -0
  106. package/dist/index.cjs +798 -0
  107. package/dist/index.d.cts +301 -0
  108. package/dist/index.d.ts +301 -0
  109. package/dist/index.js +775 -0
  110. package/index.ts +20 -0
  111. package/package.exports.json +18 -0
  112. package/package.json +45 -0
  113. package/transformers/copies/copy.ts +18 -0
  114. package/transformers/copies/copy_to.ts +226 -0
  115. package/transformers/copies/mobx_copy.ts +81 -0
  116. package/transformers/copies/specs/copy_to.tests.ts +143 -0
  117. package/transformers/copies/specs/mobx_copy.tests.ts +26 -0
  118. package/transformers/flatteners/flatten_accessors_of.ts +43 -0
  119. package/transformers/flatteners/flatten_json_value_to_type_paths_of.ts +39 -0
  120. package/transformers/flatteners/flatten_type_def_to.ts +127 -0
  121. package/transformers/flatteners/flatten_type_defs_of.ts +16 -0
  122. package/transformers/flatteners/flatten_value_type_to.ts +227 -0
  123. package/transformers/flatteners/flatten_value_types_of.ts +23 -0
  124. package/transformers/flatteners/json_path.ts +15 -0
  125. package/transformers/flatteners/specs/flatten_accessors_of.tests.ts +113 -0
  126. package/transformers/flatteners/specs/flatten_json_value_to_type_paths_of.tests.ts +115 -0
  127. package/transformers/flatteners/specs/flatten_type_def_to.tests.ts +146 -0
  128. package/transformers/flatteners/specs/flatten_type_defs_of.tests.ts +26 -0
  129. package/transformers/flatteners/specs/flatten_value_type_to.tests.ts +452 -0
  130. package/transformers/flatteners/specs/flatten_value_types_of.tests.ts +46 -0
  131. package/transformers/flatteners/specs/value_path_to_type_path.tests.ts +240 -0
  132. package/transformers/flatteners/value_path_to_type_path.ts +164 -0
  133. package/tsconfig.build.json +11 -0
  134. package/tsconfig.json +15 -0
  135. package/tsup.config.ts +16 -0
  136. package/types/builders.ts +284 -0
  137. package/types/definitions.ts +106 -0
  138. package/types/flattened.ts +5 -0
  139. package/types/flattened_accessors_of.ts +15 -0
  140. package/types/flattened_type_defs_of.ts +130 -0
  141. package/types/flattened_value_types_of.ts +11 -0
  142. package/types/json_path_of.ts +7 -0
  143. package/types/json_paths_of.ts +129 -0
  144. package/types/mobx_value_type_of.ts +16 -0
  145. package/types/partial_type_def_of.ts +64 -0
  146. package/types/readonly_type_def_of.ts +53 -0
  147. package/types/specs/builder.tests.ts +295 -0
  148. package/types/specs/flattened_accessors_of.tests.ts +27 -0
  149. package/types/specs/flattened_type_defs_of.tests.ts +212 -0
  150. package/types/specs/flattened_value_types_of.tests.ts +21 -0
  151. package/types/specs/json_paths_of.tests.ts +304 -0
  152. package/types/specs/partial_type_def_of.tests.ts +251 -0
  153. package/types/specs/readonly_type_def_of.tests.ts +158 -0
  154. package/types/specs/strict_definitions.tests.ts +184 -0
  155. package/types/specs/value_to_type_paths_of.tests.ts +181 -0
  156. package/types/specs/value_type_of.tests.ts +329 -0
  157. package/types/specs/value_types_of_discriminated_union.tests.ts +30 -0
  158. package/types/strict_definitions.ts +107 -0
  159. package/types/value_to_type_paths_of.ts +184 -0
  160. package/types/value_type_of.ts +84 -0
  161. package/types/value_types_of_discriminated_union.ts +14 -0
  162. package/vitest.workspace.ts +11 -0
@@ -0,0 +1,240 @@
1
+ import { valuePathToTypePath } from 'transformers/flatteners/value_path_to_type_path'
2
+ import {
3
+ booleanType,
4
+ list,
5
+ numberType,
6
+ object,
7
+ record,
8
+ stringType,
9
+ union,
10
+ } from 'types/builders'
11
+ import { type ValueToTypePathsOf } from 'types/value_to_type_paths_of'
12
+
13
+ describe('valuePathToTypePath', function () {
14
+ describe('literal', function () {
15
+ const typeDef = numberType
16
+ type JsonPaths = ValueToTypePathsOf<typeof typeDef>
17
+
18
+ const typePath = valuePathToTypePath<JsonPaths, '$'>(typeDef, '$')
19
+
20
+ it('maps a value path to the expected type path', function () {
21
+ expect(typePath).toEqual('$')
22
+ })
23
+
24
+ it('has expected type', function () {
25
+ expectTypeOf(typePath).toEqualTypeOf<'$'>()
26
+ })
27
+
28
+ describe('fake subpath', function () {
29
+ const fakeTypePath = valuePathToTypePath<{
30
+ '$.fake': '$.fake',
31
+ }, '$.fake'>(typeDef, '$.fake', true)
32
+
33
+ it('maps a value path to the expected type path', function () {
34
+ expect(fakeTypePath).toEqual('$.fake')
35
+ })
36
+
37
+ it('has expected type', function () {
38
+ expectTypeOf(fakeTypePath).toEqualTypeOf<'$.fake'>()
39
+ })
40
+ })
41
+ })
42
+
43
+ describe('list', function () {
44
+ const typeDef = list(numberType)
45
+ type JsonPaths = ValueToTypePathsOf<typeof typeDef>
46
+
47
+ describe.each([
48
+ [
49
+ '$',
50
+ '$',
51
+ ],
52
+ [
53
+ '$.0',
54
+ '$.*',
55
+ ],
56
+ ] as const)('it maps "%s"', function (from, to) {
57
+ const typePath = valuePathToTypePath<JsonPaths, typeof from>(typeDef, from)
58
+
59
+ it('maps a value path to the expected type path', function () {
60
+ expect(typePath).toEqual(to)
61
+ })
62
+
63
+ it('has expected type', function () {
64
+ expectTypeOf(typePath).toEqualTypeOf(to)
65
+ })
66
+ })
67
+
68
+ describe('fake subpath', function () {
69
+ const fakeTypePath = valuePathToTypePath<
70
+ JsonPaths & {
71
+ [_: `$.${number}.fake`]: '$.*.fake',
72
+ },
73
+ '$.0.fake'
74
+ >(typeDef, '$.0.fake', true)
75
+
76
+ it('maps a value path to the expected type path', function () {
77
+ expect(fakeTypePath).toEqual('$.*.fake')
78
+ })
79
+
80
+ it('has expected type', function () {
81
+ expectTypeOf(fakeTypePath).toEqualTypeOf<'$.*.fake'>()
82
+ })
83
+ })
84
+ })
85
+
86
+ describe('record', function () {
87
+ type Key = 'a' | 'b'
88
+ const typeDef = record<typeof numberType, Key>(numberType)
89
+ type JsonPaths = ValueToTypePathsOf<typeof typeDef>
90
+
91
+ describe.each([
92
+ [
93
+ '$',
94
+ '$',
95
+ ],
96
+ [
97
+ '$.a',
98
+ '$.*',
99
+ ],
100
+ [
101
+ '$.b',
102
+ '$.*',
103
+ ],
104
+ ] as const)('it maps "%s"', function (from, to) {
105
+ const typePath = valuePathToTypePath<JsonPaths, typeof from>(typeDef, from)
106
+
107
+ it('maps a value path to the expected type path', function () {
108
+ expect(typePath).toEqual(to)
109
+ })
110
+
111
+ it('has expected type', function () {
112
+ expectTypeOf(typePath).toEqualTypeOf(to)
113
+ })
114
+ })
115
+
116
+ describe('fake subpath', function () {
117
+ const fakeTypePath = valuePathToTypePath<
118
+ JsonPaths & {
119
+ '$.a.fake': '$.*.fake',
120
+ '$.b.fake': '$.*.fake',
121
+ },
122
+ '$.a.fake'
123
+ >(typeDef, '$.a.fake', true)
124
+
125
+ it('maps a value path to the expected type path', function () {
126
+ expect(fakeTypePath).toEqual('$.*.fake')
127
+ })
128
+
129
+ it('has expected type', function () {
130
+ expectTypeOf(fakeTypePath).toEqualTypeOf<'$.*.fake'>()
131
+ })
132
+ })
133
+ })
134
+
135
+ describe('object', function () {
136
+ const typeDef = object().set('a', numberType).set('b', booleanType)
137
+ type JsonPaths = ValueToTypePathsOf<typeof typeDef>
138
+
139
+ describe.each([
140
+ [
141
+ '$',
142
+ '$',
143
+ ],
144
+ [
145
+ '$.a',
146
+ '$.a',
147
+ ],
148
+ [
149
+ '$.b',
150
+ '$.b',
151
+ ],
152
+ ] as const)('it maps %s', function (from, to) {
153
+ const typePath = valuePathToTypePath<JsonPaths, typeof from>(typeDef, from)
154
+
155
+ it('maps a value path to the expected type path', function () {
156
+ expect(typePath).toEqual(to)
157
+ })
158
+
159
+ it('has expected type', function () {
160
+ expectTypeOf(typePath).toEqualTypeOf(to)
161
+ })
162
+ })
163
+
164
+ describe('fake field', function () {
165
+ const fakeTypePath = valuePathToTypePath<
166
+ JsonPaths & {
167
+ '$.fake': '$.fake',
168
+ },
169
+ '$.fake'
170
+ >(typeDef, '$.fake', true)
171
+
172
+ it('maps a value path to the expected type path', function () {
173
+ expect(fakeTypePath).toEqual('$.fake')
174
+ })
175
+
176
+ it('has expected type', function () {
177
+ expectTypeOf(fakeTypePath).toEqualTypeOf<'$.fake'>()
178
+ })
179
+ })
180
+ })
181
+
182
+ describe('union', function () {
183
+ describe('discriminated', function () {
184
+ const typeDef = union('w')
185
+ .add('x', object().set('a', numberType).set('b', booleanType))
186
+ .add('y', object().set('b', stringType).set('c', booleanType))
187
+ type JsonPaths = ValueToTypePathsOf<typeof typeDef>
188
+
189
+ describe.each([
190
+ [
191
+ '$',
192
+ '$',
193
+ ],
194
+ [
195
+ '$.x:a',
196
+ '$.x:a',
197
+ ],
198
+ [
199
+ '$.x:b',
200
+ '$.x:b',
201
+ ],
202
+ [
203
+ '$.y:b',
204
+ '$.y:b',
205
+ ],
206
+ [
207
+ '$.y:c',
208
+ '$.y:c',
209
+ ],
210
+ ] as const)('it maps %s', function (from, to) {
211
+ const typePath = valuePathToTypePath<JsonPaths, typeof from>(typeDef, from)
212
+
213
+ it('maps a value path to the expected type path', function () {
214
+ expect(typePath).toEqual(to)
215
+ })
216
+
217
+ it('has expected type', function () {
218
+ expectTypeOf(typePath).toEqualTypeOf(to)
219
+ })
220
+ })
221
+
222
+ describe('fake', function () {
223
+ const fakeTypePath = valuePathToTypePath<
224
+ JsonPaths & {
225
+ '$.fake': '$.fake',
226
+ },
227
+ '$.fake'
228
+ >(typeDef, '$.fake', true)
229
+
230
+ it('maps a value path to the expected type path', function () {
231
+ expect(fakeTypePath).toEqual('$.fake')
232
+ })
233
+
234
+ it('has expected type', function () {
235
+ expectTypeOf(fakeTypePath).toEqualTypeOf<'$.fake'>()
236
+ })
237
+ })
238
+ })
239
+ })
240
+ })
@@ -0,0 +1,164 @@
1
+ import {
2
+ assertEqual,
3
+ assertExists,
4
+ assertExistsAndReturn,
5
+ PreconditionFailedError,
6
+ reduce,
7
+ UnreachableError,
8
+ } from '@strictly/base'
9
+ import {
10
+ type Type,
11
+ type TypeDef,
12
+ TypeDefType,
13
+ } from 'types/definitions'
14
+
15
+ export function valuePathToTypePath<
16
+ JsonPaths extends Record<string, string>,
17
+ ValuePath extends keyof JsonPaths,
18
+ >(
19
+ { definition: typeDef }: Type,
20
+ valuePath: ValuePath,
21
+ allowMissingPaths: boolean = false,
22
+ ): JsonPaths[ValuePath] {
23
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
24
+ const valueSteps = (valuePath as string).split(/\.|\[/g)
25
+ assertEqual(valueSteps[0], '$')
26
+
27
+ const typeSteps = internalJsonValuePathToTypePath(
28
+ typeDef,
29
+ valueSteps.slice(1),
30
+ allowMissingPaths,
31
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
32
+ valuePath as string,
33
+ )
34
+ typeSteps.unshift('$')
35
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
36
+ return typeSteps.join('.') as JsonPaths[ValuePath]
37
+ }
38
+
39
+ function internalJsonValuePathToTypePath(
40
+ typeDef: TypeDef,
41
+ valueSteps: string[],
42
+ allowMissingPaths: boolean,
43
+ originalValuePath: string,
44
+ ): string[] {
45
+ if (valueSteps.length === 0) {
46
+ return []
47
+ }
48
+ const [
49
+ valueStep,
50
+ ...remainingValueSteps
51
+ ] = valueSteps
52
+ switch (typeDef.type) {
53
+ case TypeDefType.Literal:
54
+ if (allowMissingPaths) {
55
+ // fake it
56
+ return valueSteps
57
+ } else {
58
+ throw new PreconditionFailedError(
59
+ 'literal should terminate path {} ({})',
60
+ originalValuePath,
61
+ valueStep,
62
+ )
63
+ }
64
+ case TypeDefType.List:
65
+ // TODO assert format of current step
66
+ return [
67
+ '*',
68
+ ...internalJsonValuePathToTypePath(
69
+ typeDef.elements,
70
+ remainingValueSteps,
71
+ allowMissingPaths,
72
+ originalValuePath,
73
+ ),
74
+ ]
75
+ case TypeDefType.Record:
76
+ return [
77
+ '*',
78
+ ...internalJsonValuePathToTypePath(
79
+ typeDef.valueTypeDef,
80
+ remainingValueSteps,
81
+ allowMissingPaths,
82
+ originalValuePath,
83
+ ),
84
+ ]
85
+ case TypeDefType.Object:
86
+ if (allowMissingPaths) {
87
+ if (typeDef.fields[valueStep] == null) {
88
+ // fake it
89
+ return valueSteps
90
+ }
91
+ } else {
92
+ assertExists(typeDef.fields[valueStep], 'missing field in {} ({})', originalValuePath, valueStep)
93
+ }
94
+ return [
95
+ valueStep,
96
+ ...internalJsonValuePathToTypePath(
97
+ typeDef.fields[valueStep],
98
+ remainingValueSteps,
99
+ allowMissingPaths,
100
+ originalValuePath,
101
+ ),
102
+ ]
103
+ case TypeDefType.Union:
104
+ if (typeDef.discriminator == null) {
105
+ if (remainingValueSteps.length > 0) {
106
+ // find the non-literal typedef
107
+ const union = reduce<string, TypeDef, null | TypeDef>(
108
+ typeDef.unions,
109
+ function (acc, _k, v) {
110
+ if (v.type !== TypeDefType.Literal || v.type === TypeDefType.Literal && v.valuePrototype == null) {
111
+ return v
112
+ }
113
+ return acc
114
+ },
115
+ null,
116
+ )
117
+ assertExists(union, 'expected a complex union {}', originalValuePath)
118
+ return internalJsonValuePathToTypePath(
119
+ union,
120
+ valueSteps,
121
+ allowMissingPaths,
122
+ originalValuePath,
123
+ )
124
+ } else {
125
+ // doesn't really matter
126
+ return []
127
+ }
128
+ } else {
129
+ const qualifierIndex = valueStep.indexOf(':')
130
+ if (qualifierIndex < 0) {
131
+ if (allowMissingPaths) {
132
+ return valueSteps
133
+ } else {
134
+ throw new PreconditionFailedError(
135
+ 'mismatched qualifiers in {} (at {})',
136
+ originalValuePath,
137
+ valueStep,
138
+ )
139
+ }
140
+ }
141
+ const qualifier = valueStep.substring(0, qualifierIndex)
142
+ const remainder = valueStep.substring(qualifierIndex + 1)
143
+ const union = assertExistsAndReturn(typeDef.unions[qualifier], 'missing union {}', qualifier)
144
+ const [
145
+ typeStep,
146
+ ...remainingTypeSteps
147
+ ] = internalJsonValuePathToTypePath(
148
+ union,
149
+ [
150
+ remainder,
151
+ ...remainingValueSteps,
152
+ ],
153
+ allowMissingPaths,
154
+ originalValuePath,
155
+ )
156
+ return [
157
+ `${qualifier}:${typeStep}`,
158
+ ...remainingTypeSteps,
159
+ ]
160
+ }
161
+ default:
162
+ throw new UnreachableError(typeDef)
163
+ }
164
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": "."
4
+ },
5
+ "extends": "../../tsconfig.build.json",
6
+ "include": [
7
+ ".eslintrc.cjs",
8
+ "tsup.config.ts",
9
+ "vitest.workspace.ts"
10
+ ]
11
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "outDir": "./.out"
5
+ },
6
+ "extends": "../../tsconfig.json",
7
+ "include": [
8
+ "**/*.ts",
9
+ "tsconfig.json"
10
+ ],
11
+ "references": [
12
+ {"path": "../base"},
13
+ {"path": "../../support/vite"}
14
+ ]
15
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,16 @@
1
+ import {
2
+ defineConfig,
3
+ type Options,
4
+ } from 'tsup'
5
+
6
+ export default defineConfig((options: Options) => ({
7
+ entry: ['index.ts'],
8
+ tsconfig: './tsconfig.build.json',
9
+ clean: false,
10
+ dts: true,
11
+ format: [
12
+ 'cjs',
13
+ 'esm',
14
+ ],
15
+ ...options,
16
+ }))