typia 4.0.0 → 4.0.1-dev.20230604

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 (87) hide show
  1. package/lib/programmers/ApplicationProgrammer.js +1 -1
  2. package/lib/programmers/internal/application_array.js +19 -41
  3. package/lib/programmers/internal/application_array.js.map +1 -1
  4. package/lib/programmers/internal/application_definition.d.ts +1 -1
  5. package/lib/programmers/internal/application_definition.js +8 -8
  6. package/lib/programmers/internal/application_definition.js.map +1 -1
  7. package/lib/programmers/internal/application_native.js +3 -3
  8. package/lib/programmers/internal/application_object.js +4 -4
  9. package/lib/programmers/internal/application_schema.js +3 -3
  10. package/lib/programmers/internal/application_schema.js.map +1 -1
  11. package/lib/programmers/internal/application_tuple.js +8 -30
  12. package/lib/programmers/internal/application_tuple.js.map +1 -1
  13. package/lib/schemas/IJsonComponents.d.ts +1 -12
  14. package/lib/schemas/IJsonSchema.d.ts +1 -1
  15. package/package.json +1 -1
  16. package/src/IRandomGenerator.ts +34 -34
  17. package/src/factories/IdentifierFactory.ts +65 -65
  18. package/src/factories/MetadataCollection.ts +254 -254
  19. package/src/factories/MetadataFactory.ts +40 -40
  20. package/src/factories/MetadataTagFactory.ts +300 -300
  21. package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -34
  22. package/src/factories/internal/metadata/emplace_metadata_definition.ts +35 -35
  23. package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
  24. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -50
  25. package/src/factories/internal/metadata/explore_metadata.ts +66 -66
  26. package/src/factories/internal/metadata/iterate_metadata.ts +77 -77
  27. package/src/factories/internal/metadata/iterate_metadata_array.ts +25 -25
  28. package/src/factories/internal/metadata/iterate_metadata_collection.ts +130 -130
  29. package/src/factories/internal/metadata/iterate_metadata_definition.ts +30 -30
  30. package/src/factories/internal/metadata/iterate_metadata_object.ts +49 -49
  31. package/src/factories/internal/metadata/iterate_metadata_sort.ts +68 -68
  32. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +24 -24
  33. package/src/factories/internal/metadata/iterate_metadata_union.ts +68 -68
  34. package/src/metadata/IMetadata.ts +27 -27
  35. package/src/metadata/IMetadataAlias.ts +12 -12
  36. package/src/metadata/IMetadataApplication.ts +7 -7
  37. package/src/metadata/IMetadataArray.ts +10 -10
  38. package/src/metadata/IMetadataCollection.ts +11 -11
  39. package/src/metadata/IMetadataDictionary.ts +14 -14
  40. package/src/metadata/IMetadataObject.ts +18 -18
  41. package/src/metadata/IMetadataProperty.ts +11 -11
  42. package/src/metadata/IMetadataTuple.ts +10 -10
  43. package/src/metadata/Metadata.ts +585 -585
  44. package/src/metadata/MetadataAlias.ts +61 -61
  45. package/src/metadata/MetadataArray.ts +52 -52
  46. package/src/metadata/MetadataObject.ts +114 -114
  47. package/src/metadata/MetadataProperty.ts +64 -64
  48. package/src/metadata/MetadataTuple.ts +53 -53
  49. package/src/programmers/ApplicationProgrammer.ts +55 -55
  50. package/src/programmers/AssertProgrammer.ts +291 -291
  51. package/src/programmers/CheckerProgrammer.ts +1182 -1182
  52. package/src/programmers/CloneProgrammer.ts +595 -595
  53. package/src/programmers/FeatureProgrammer.ts +495 -495
  54. package/src/programmers/IsProgrammer.ts +250 -250
  55. package/src/programmers/LiteralsProgrammer.ts +66 -66
  56. package/src/programmers/PruneProgrammer.ts +550 -550
  57. package/src/programmers/RandomProgrammer.ts +589 -589
  58. package/src/programmers/StringifyProgrammer.ts +990 -990
  59. package/src/programmers/ValidateProgrammer.ts +313 -313
  60. package/src/programmers/helpers/FunctionImporeter.ts +78 -78
  61. package/src/programmers/helpers/RandomJoiner.ts +173 -173
  62. package/src/programmers/helpers/UnionExplorer.ts +301 -301
  63. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  64. package/src/programmers/helpers/disable_function_importer_declare.ts +26 -26
  65. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  66. package/src/programmers/internal/application_array.ts +30 -64
  67. package/src/programmers/internal/application_boolean.ts +15 -15
  68. package/src/programmers/internal/application_constant.ts +26 -26
  69. package/src/programmers/internal/application_default.ts +17 -17
  70. package/src/programmers/internal/application_definition.ts +45 -45
  71. package/src/programmers/internal/application_native.ts +39 -39
  72. package/src/programmers/internal/application_number.ts +74 -74
  73. package/src/programmers/internal/application_object.ts +167 -167
  74. package/src/programmers/internal/application_schema.ts +156 -164
  75. package/src/programmers/internal/application_tuple.ts +47 -77
  76. package/src/programmers/internal/check_union_array_like.ts +329 -329
  77. package/src/programmers/internal/feature_object_entries.ts +63 -63
  78. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -16
  79. package/src/schemas/IJsonApplication.ts +8 -8
  80. package/src/schemas/IJsonComponents.ts +34 -45
  81. package/src/schemas/IJsonSchema.ts +134 -134
  82. package/src/transformers/CallExpressionTransformer.ts +179 -179
  83. package/src/transformers/FileTransformer.ts +47 -47
  84. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +104 -104
  85. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +53 -53
  86. package/src/utils/ArrayUtil.ts +45 -45
  87. package/src/utils/RandomGenerator.ts +81 -81
@@ -1,291 +1,291 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../factories/IdentifierFactory";
4
- import { StatementFactory } from "../factories/StatementFactory";
5
- import { TypeFactory } from "../factories/TypeFactory";
6
-
7
- import { IProject } from "../transformers/IProject";
8
-
9
- import { CheckerProgrammer } from "./CheckerProgrammer";
10
- import { IsProgrammer } from "./IsProgrammer";
11
- import { FunctionImporter } from "./helpers/FunctionImporeter";
12
- import { OptionPredicator } from "./helpers/OptionPredicator";
13
- import { check_object } from "./internal/check_object";
14
-
15
- export namespace AssertProgrammer {
16
- /**
17
- * @deprecated Use `write()` function instead
18
- */
19
- export const generate =
20
- (
21
- project: IProject,
22
- modulo: ts.LeftHandSideExpression,
23
- equals: boolean = false,
24
- ) =>
25
- (type: ts.Type, name?: string) =>
26
- write(project)(modulo)(equals)(type, name);
27
-
28
- export const write =
29
- (project: IProject) =>
30
- (modulo: ts.LeftHandSideExpression) =>
31
- (equals: boolean) =>
32
- (type: ts.Type, name?: string) => {
33
- const importer: FunctionImporter = new FunctionImporter();
34
- const is = IsProgrammer.write(project)(modulo, true)(equals)(
35
- type,
36
- name ?? TypeFactory.getFullName(project.checker)(type),
37
- );
38
- const assert: ts.ArrowFunction = CheckerProgrammer.write(project)({
39
- prefix: "$a",
40
- path: true,
41
- trace: true,
42
- numeric: OptionPredicator.numeric(project.options),
43
- equals,
44
- atomist: (explore) => (tuple) => (input) =>
45
- [
46
- tuple.expression,
47
- ...tuple.tags.map((tag) =>
48
- ts.factory.createLogicalOr(
49
- tag.expression,
50
- create_guard_call(importer)(
51
- explore.from === "top"
52
- ? ts.factory.createTrue()
53
- : ts.factory.createIdentifier(
54
- "_exceptionable",
55
- ),
56
- )(
57
- ts.factory.createIdentifier(
58
- explore.postfix
59
- ? `_path + ${explore.postfix}`
60
- : "_path",
61
- ),
62
- tag.expected,
63
- input,
64
- ),
65
- ),
66
- ),
67
- ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
68
- combiner: combiner(equals)(importer),
69
- joiner: joiner(equals)(importer),
70
- success: ts.factory.createTrue(),
71
- addition: () => importer.declare(modulo),
72
- })(importer)(type, name);
73
-
74
- return ts.factory.createArrowFunction(
75
- undefined,
76
- undefined,
77
- [
78
- IdentifierFactory.parameter(
79
- "input",
80
- TypeFactory.keyword("any"),
81
- ),
82
- ],
83
- ts.factory.createTypeReferenceNode(
84
- name ?? TypeFactory.getFullName(project.checker)(type),
85
- ),
86
- undefined,
87
- ts.factory.createBlock(
88
- [
89
- StatementFactory.constant("__is", is),
90
- ts.factory.createIfStatement(
91
- ts.factory.createStrictEquality(
92
- ts.factory.createFalse(),
93
- ts.factory.createCallExpression(
94
- ts.factory.createIdentifier("__is"),
95
- undefined,
96
- [ts.factory.createIdentifier("input")],
97
- ),
98
- ),
99
- ts.factory.createExpressionStatement(
100
- ts.factory.createCallExpression(
101
- assert,
102
- undefined,
103
- [
104
- ts.factory.createIdentifier("input"),
105
- ts.factory.createStringLiteral(
106
- "$input",
107
- ),
108
- ts.factory.createTrue(),
109
- ],
110
- ),
111
- ),
112
- undefined,
113
- ),
114
- ts.factory.createReturnStatement(
115
- ts.factory.createIdentifier(`input`),
116
- ),
117
- ],
118
- true,
119
- ),
120
- );
121
- };
122
-
123
- const combiner =
124
- (equals: boolean) =>
125
- (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
126
- (explore: CheckerProgrammer.IExplore) => {
127
- if (explore.tracable === false)
128
- return IsProgrammer.configure({
129
- object: assert_object(equals)(importer),
130
- numeric: true,
131
- })(importer).combiner(explore);
132
-
133
- const path: string = explore.postfix
134
- ? `_path + ${explore.postfix}`
135
- : "_path";
136
- return (logic) => (input, binaries, expected) =>
137
- logic === "and"
138
- ? binaries
139
- .map((binary) =>
140
- binary.combined
141
- ? binary.expression
142
- : ts.factory.createLogicalOr(
143
- binary.expression,
144
- create_guard_call(importer)(
145
- explore.source === "top"
146
- ? ts.factory.createTrue()
147
- : ts.factory.createIdentifier(
148
- "_exceptionable",
149
- ),
150
- )(
151
- ts.factory.createIdentifier(path),
152
- expected,
153
- input,
154
- ),
155
- ),
156
- )
157
- .reduce(ts.factory.createLogicalAnd)
158
- : ts.factory.createLogicalOr(
159
- binaries
160
- .map((binary) => binary.expression)
161
- .reduce(ts.factory.createLogicalOr),
162
- create_guard_call(importer)(
163
- explore.source === "top"
164
- ? ts.factory.createTrue()
165
- : ts.factory.createIdentifier(
166
- "_exceptionable",
167
- ),
168
- )(ts.factory.createIdentifier(path), expected, input),
169
- );
170
- // : (() => {
171
- // const addicted = binaries.slice();
172
- // if (
173
- // addicted[addicted.length - 1]!.combined === false
174
- // ) {
175
- // addicted.push({
176
- // combined: true,
177
- // expression: create_guard_call(importer)(
178
- // explore.source === "top"
179
- // ? ts.factory.createTrue()
180
- // : ts.factory.createIdentifier(
181
- // "_exceptionable",
182
- // ),
183
- // )(
184
- // ts.factory.createIdentifier(path),
185
- // expected,
186
- // input,
187
- // ),
188
- // });
189
- // }
190
- // return addicted
191
- // .map((b) => b.expression)
192
- // .reduce(ts.factory.createLogicalOr);
193
- // })();
194
- };
195
-
196
- const assert_object = (equals: boolean) => (importer: FunctionImporter) =>
197
- check_object({
198
- equals,
199
- assert: true,
200
- undefined: true,
201
- reduce: ts.factory.createLogicalAnd,
202
- positive: ts.factory.createTrue(),
203
- superfluous: (value) =>
204
- create_guard_call(importer)()(
205
- ts.factory.createAdd(
206
- ts.factory.createIdentifier("_path"),
207
- ts.factory.createCallExpression(
208
- importer.use("join"),
209
- undefined,
210
- [ts.factory.createIdentifier("key")],
211
- ),
212
- ),
213
- "undefined",
214
- value,
215
- ),
216
- halt: (expr) =>
217
- ts.factory.createLogicalOr(
218
- ts.factory.createStrictEquality(
219
- ts.factory.createFalse(),
220
- ts.factory.createIdentifier("_exceptionable"),
221
- ),
222
- expr,
223
- ),
224
- })(importer);
225
-
226
- const joiner =
227
- (equals: boolean) =>
228
- (importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
229
- object: assert_object(equals)(importer),
230
- array: (input, arrow) =>
231
- ts.factory.createCallExpression(
232
- IdentifierFactory.access(input)("every"),
233
- undefined,
234
- [arrow],
235
- ),
236
- failure: (value, expected, explore) =>
237
- create_guard_call(importer)(
238
- explore?.from === "top"
239
- ? ts.factory.createTrue()
240
- : ts.factory.createIdentifier("_exceptionable"),
241
- )(
242
- ts.factory.createIdentifier(
243
- explore?.postfix
244
- ? `_path + ${explore.postfix}`
245
- : "_path",
246
- ),
247
- expected,
248
- value,
249
- ),
250
- full: equals
251
- ? undefined
252
- : (condition) => (input, expected, explore) =>
253
- ts.factory.createLogicalOr(
254
- condition,
255
- create_guard_call(importer)(
256
- explore.from === "top"
257
- ? ts.factory.createTrue()
258
- : ts.factory.createIdentifier(
259
- "_exceptionable",
260
- ),
261
- )(
262
- ts.factory.createIdentifier("_path"),
263
- expected,
264
- input,
265
- ),
266
- ),
267
- });
268
-
269
- const create_guard_call =
270
- (importer: FunctionImporter) =>
271
- (exceptionable?: ts.Expression) =>
272
- (
273
- path: ts.Expression,
274
- expected: string,
275
- value: ts.Expression,
276
- ): ts.Expression =>
277
- ts.factory.createCallExpression(importer.use("guard"), undefined, [
278
- exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
279
- ts.factory.createObjectLiteralExpression(
280
- [
281
- ts.factory.createPropertyAssignment("path", path),
282
- ts.factory.createPropertyAssignment(
283
- "expected",
284
- ts.factory.createStringLiteral(expected),
285
- ),
286
- ts.factory.createPropertyAssignment("value", value),
287
- ],
288
- true,
289
- ),
290
- ]);
291
- }
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../factories/IdentifierFactory";
4
+ import { StatementFactory } from "../factories/StatementFactory";
5
+ import { TypeFactory } from "../factories/TypeFactory";
6
+
7
+ import { IProject } from "../transformers/IProject";
8
+
9
+ import { CheckerProgrammer } from "./CheckerProgrammer";
10
+ import { IsProgrammer } from "./IsProgrammer";
11
+ import { FunctionImporter } from "./helpers/FunctionImporeter";
12
+ import { OptionPredicator } from "./helpers/OptionPredicator";
13
+ import { check_object } from "./internal/check_object";
14
+
15
+ export namespace AssertProgrammer {
16
+ /**
17
+ * @deprecated Use `write()` function instead
18
+ */
19
+ export const generate =
20
+ (
21
+ project: IProject,
22
+ modulo: ts.LeftHandSideExpression,
23
+ equals: boolean = false,
24
+ ) =>
25
+ (type: ts.Type, name?: string) =>
26
+ write(project)(modulo)(equals)(type, name);
27
+
28
+ export const write =
29
+ (project: IProject) =>
30
+ (modulo: ts.LeftHandSideExpression) =>
31
+ (equals: boolean) =>
32
+ (type: ts.Type, name?: string) => {
33
+ const importer: FunctionImporter = new FunctionImporter();
34
+ const is = IsProgrammer.write(project)(modulo, true)(equals)(
35
+ type,
36
+ name ?? TypeFactory.getFullName(project.checker)(type),
37
+ );
38
+ const assert: ts.ArrowFunction = CheckerProgrammer.write(project)({
39
+ prefix: "$a",
40
+ path: true,
41
+ trace: true,
42
+ numeric: OptionPredicator.numeric(project.options),
43
+ equals,
44
+ atomist: (explore) => (tuple) => (input) =>
45
+ [
46
+ tuple.expression,
47
+ ...tuple.tags.map((tag) =>
48
+ ts.factory.createLogicalOr(
49
+ tag.expression,
50
+ create_guard_call(importer)(
51
+ explore.from === "top"
52
+ ? ts.factory.createTrue()
53
+ : ts.factory.createIdentifier(
54
+ "_exceptionable",
55
+ ),
56
+ )(
57
+ ts.factory.createIdentifier(
58
+ explore.postfix
59
+ ? `_path + ${explore.postfix}`
60
+ : "_path",
61
+ ),
62
+ tag.expected,
63
+ input,
64
+ ),
65
+ ),
66
+ ),
67
+ ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
68
+ combiner: combiner(equals)(importer),
69
+ joiner: joiner(equals)(importer),
70
+ success: ts.factory.createTrue(),
71
+ addition: () => importer.declare(modulo),
72
+ })(importer)(type, name);
73
+
74
+ return ts.factory.createArrowFunction(
75
+ undefined,
76
+ undefined,
77
+ [
78
+ IdentifierFactory.parameter(
79
+ "input",
80
+ TypeFactory.keyword("any"),
81
+ ),
82
+ ],
83
+ ts.factory.createTypeReferenceNode(
84
+ name ?? TypeFactory.getFullName(project.checker)(type),
85
+ ),
86
+ undefined,
87
+ ts.factory.createBlock(
88
+ [
89
+ StatementFactory.constant("__is", is),
90
+ ts.factory.createIfStatement(
91
+ ts.factory.createStrictEquality(
92
+ ts.factory.createFalse(),
93
+ ts.factory.createCallExpression(
94
+ ts.factory.createIdentifier("__is"),
95
+ undefined,
96
+ [ts.factory.createIdentifier("input")],
97
+ ),
98
+ ),
99
+ ts.factory.createExpressionStatement(
100
+ ts.factory.createCallExpression(
101
+ assert,
102
+ undefined,
103
+ [
104
+ ts.factory.createIdentifier("input"),
105
+ ts.factory.createStringLiteral(
106
+ "$input",
107
+ ),
108
+ ts.factory.createTrue(),
109
+ ],
110
+ ),
111
+ ),
112
+ undefined,
113
+ ),
114
+ ts.factory.createReturnStatement(
115
+ ts.factory.createIdentifier(`input`),
116
+ ),
117
+ ],
118
+ true,
119
+ ),
120
+ );
121
+ };
122
+
123
+ const combiner =
124
+ (equals: boolean) =>
125
+ (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
126
+ (explore: CheckerProgrammer.IExplore) => {
127
+ if (explore.tracable === false)
128
+ return IsProgrammer.configure({
129
+ object: assert_object(equals)(importer),
130
+ numeric: true,
131
+ })(importer).combiner(explore);
132
+
133
+ const path: string = explore.postfix
134
+ ? `_path + ${explore.postfix}`
135
+ : "_path";
136
+ return (logic) => (input, binaries, expected) =>
137
+ logic === "and"
138
+ ? binaries
139
+ .map((binary) =>
140
+ binary.combined
141
+ ? binary.expression
142
+ : ts.factory.createLogicalOr(
143
+ binary.expression,
144
+ create_guard_call(importer)(
145
+ explore.source === "top"
146
+ ? ts.factory.createTrue()
147
+ : ts.factory.createIdentifier(
148
+ "_exceptionable",
149
+ ),
150
+ )(
151
+ ts.factory.createIdentifier(path),
152
+ expected,
153
+ input,
154
+ ),
155
+ ),
156
+ )
157
+ .reduce(ts.factory.createLogicalAnd)
158
+ : ts.factory.createLogicalOr(
159
+ binaries
160
+ .map((binary) => binary.expression)
161
+ .reduce(ts.factory.createLogicalOr),
162
+ create_guard_call(importer)(
163
+ explore.source === "top"
164
+ ? ts.factory.createTrue()
165
+ : ts.factory.createIdentifier(
166
+ "_exceptionable",
167
+ ),
168
+ )(ts.factory.createIdentifier(path), expected, input),
169
+ );
170
+ // : (() => {
171
+ // const addicted = binaries.slice();
172
+ // if (
173
+ // addicted[addicted.length - 1]!.combined === false
174
+ // ) {
175
+ // addicted.push({
176
+ // combined: true,
177
+ // expression: create_guard_call(importer)(
178
+ // explore.source === "top"
179
+ // ? ts.factory.createTrue()
180
+ // : ts.factory.createIdentifier(
181
+ // "_exceptionable",
182
+ // ),
183
+ // )(
184
+ // ts.factory.createIdentifier(path),
185
+ // expected,
186
+ // input,
187
+ // ),
188
+ // });
189
+ // }
190
+ // return addicted
191
+ // .map((b) => b.expression)
192
+ // .reduce(ts.factory.createLogicalOr);
193
+ // })();
194
+ };
195
+
196
+ const assert_object = (equals: boolean) => (importer: FunctionImporter) =>
197
+ check_object({
198
+ equals,
199
+ assert: true,
200
+ undefined: true,
201
+ reduce: ts.factory.createLogicalAnd,
202
+ positive: ts.factory.createTrue(),
203
+ superfluous: (value) =>
204
+ create_guard_call(importer)()(
205
+ ts.factory.createAdd(
206
+ ts.factory.createIdentifier("_path"),
207
+ ts.factory.createCallExpression(
208
+ importer.use("join"),
209
+ undefined,
210
+ [ts.factory.createIdentifier("key")],
211
+ ),
212
+ ),
213
+ "undefined",
214
+ value,
215
+ ),
216
+ halt: (expr) =>
217
+ ts.factory.createLogicalOr(
218
+ ts.factory.createStrictEquality(
219
+ ts.factory.createFalse(),
220
+ ts.factory.createIdentifier("_exceptionable"),
221
+ ),
222
+ expr,
223
+ ),
224
+ })(importer);
225
+
226
+ const joiner =
227
+ (equals: boolean) =>
228
+ (importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
229
+ object: assert_object(equals)(importer),
230
+ array: (input, arrow) =>
231
+ ts.factory.createCallExpression(
232
+ IdentifierFactory.access(input)("every"),
233
+ undefined,
234
+ [arrow],
235
+ ),
236
+ failure: (value, expected, explore) =>
237
+ create_guard_call(importer)(
238
+ explore?.from === "top"
239
+ ? ts.factory.createTrue()
240
+ : ts.factory.createIdentifier("_exceptionable"),
241
+ )(
242
+ ts.factory.createIdentifier(
243
+ explore?.postfix
244
+ ? `_path + ${explore.postfix}`
245
+ : "_path",
246
+ ),
247
+ expected,
248
+ value,
249
+ ),
250
+ full: equals
251
+ ? undefined
252
+ : (condition) => (input, expected, explore) =>
253
+ ts.factory.createLogicalOr(
254
+ condition,
255
+ create_guard_call(importer)(
256
+ explore.from === "top"
257
+ ? ts.factory.createTrue()
258
+ : ts.factory.createIdentifier(
259
+ "_exceptionable",
260
+ ),
261
+ )(
262
+ ts.factory.createIdentifier("_path"),
263
+ expected,
264
+ input,
265
+ ),
266
+ ),
267
+ });
268
+
269
+ const create_guard_call =
270
+ (importer: FunctionImporter) =>
271
+ (exceptionable?: ts.Expression) =>
272
+ (
273
+ path: ts.Expression,
274
+ expected: string,
275
+ value: ts.Expression,
276
+ ): ts.Expression =>
277
+ ts.factory.createCallExpression(importer.use("guard"), undefined, [
278
+ exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
279
+ ts.factory.createObjectLiteralExpression(
280
+ [
281
+ ts.factory.createPropertyAssignment("path", path),
282
+ ts.factory.createPropertyAssignment(
283
+ "expected",
284
+ ts.factory.createStringLiteral(expected),
285
+ ),
286
+ ts.factory.createPropertyAssignment("value", value),
287
+ ],
288
+ true,
289
+ ),
290
+ ]);
291
+ }