typia 4.0.0-dev.20230519-3 → 4.0.0-dev.20230527

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 (222) hide show
  1. package/lib/transform.js +1 -1
  2. package/lib/transform.js.map +1 -1
  3. package/lib/utils/TsSymbolUtil.js +2 -1
  4. package/lib/utils/TsSymbolUtil.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/CustomValidatorMap.ts +126 -126
  7. package/src/IRandomGenerator.ts +33 -33
  8. package/src/IValidation.ts +21 -21
  9. package/src/Primitive.ts +123 -123
  10. package/src/TypeGuardError.ts +36 -36
  11. package/src/executable/TypiaGenerateWizard.ts +85 -85
  12. package/src/executable/TypiaSetupWizard.ts +133 -133
  13. package/src/executable/setup/ArgumentParser.ts +45 -45
  14. package/src/executable/setup/CommandExecutor.ts +8 -8
  15. package/src/executable/setup/FileRetriever.ts +22 -22
  16. package/src/executable/setup/PackageManager.ts +71 -71
  17. package/src/executable/setup/PluginConfigurator.ts +70 -70
  18. package/src/executable/typia.ts +52 -52
  19. package/src/factories/CommentFactory.ts +14 -14
  20. package/src/factories/ExpressionFactory.ts +77 -77
  21. package/src/factories/IdentifierFactory.ts +62 -62
  22. package/src/factories/LiteralFactory.ts +57 -57
  23. package/src/factories/MetadataCollection.ts +123 -123
  24. package/src/factories/MetadataFactory.ts +53 -53
  25. package/src/factories/MetadataTagFactory.ts +295 -295
  26. package/src/factories/StatementFactory.ts +20 -20
  27. package/src/factories/TemplateFactory.ts +64 -64
  28. package/src/factories/TypeFactory.ts +145 -145
  29. package/src/factories/ValueFactory.ts +15 -15
  30. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  31. package/src/factories/internal/metadata/emplace_metadata_object.ts +152 -152
  32. package/src/factories/internal/metadata/explore_metadata.ts +93 -93
  33. package/src/factories/internal/metadata/iterate_metadata.ts +63 -63
  34. package/src/factories/internal/metadata/iterate_metadata_array.ts +32 -32
  35. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
  36. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  37. package/src/factories/internal/metadata/iterate_metadata_constant.ts +62 -62
  38. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  39. package/src/factories/internal/metadata/iterate_metadata_native.ts +217 -217
  40. package/src/factories/internal/metadata/iterate_metadata_object.ts +51 -51
  41. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +30 -30
  42. package/src/factories/internal/metadata/iterate_metadata_set.ts +36 -36
  43. package/src/factories/internal/metadata/iterate_metadata_template.ts +40 -40
  44. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +51 -51
  45. package/src/factories/internal/metadata/iterate_metadata_union.ts +59 -59
  46. package/src/functional/$any.ts +2 -2
  47. package/src/functional/$dictionary.ts +25 -25
  48. package/src/functional/$every.ts +11 -11
  49. package/src/functional/$guard.ts +35 -35
  50. package/src/functional/$is_between.ts +2 -2
  51. package/src/functional/$is_custom.ts +14 -14
  52. package/src/functional/$is_date.ts +3 -3
  53. package/src/functional/$is_datetime.ts +2 -2
  54. package/src/functional/$is_email.ts +4 -4
  55. package/src/functional/$is_ipv4.ts +4 -4
  56. package/src/functional/$is_ipv6.ts +4 -4
  57. package/src/functional/$is_url.ts +4 -4
  58. package/src/functional/$is_uuid.ts +4 -4
  59. package/src/functional/$join.ts +46 -46
  60. package/src/functional/$number.ts +12 -12
  61. package/src/functional/$report.ts +15 -15
  62. package/src/functional/$rest.ts +3 -3
  63. package/src/functional/$string.ts +37 -37
  64. package/src/functional/$tail.ts +5 -5
  65. package/src/functional/Namespace.ts +127 -127
  66. package/src/index.ts +4 -4
  67. package/src/metadata/ICommentTag.ts +4 -4
  68. package/src/metadata/IJsDocTagInfo.ts +10 -10
  69. package/src/metadata/IMetadata.ts +26 -26
  70. package/src/metadata/IMetadataApplication.ts +7 -7
  71. package/src/metadata/IMetadataConstant.ts +16 -16
  72. package/src/metadata/IMetadataEntry.ts +6 -6
  73. package/src/metadata/IMetadataObject.ts +29 -29
  74. package/src/metadata/IMetadataProperty.ts +11 -11
  75. package/src/metadata/IMetadataTag.ts +105 -105
  76. package/src/metadata/Metadata.ts +539 -539
  77. package/src/metadata/MetadataConstant.ts +3 -3
  78. package/src/metadata/MetadataObject.ts +127 -127
  79. package/src/metadata/MetadataProperty.ts +64 -64
  80. package/src/module.ts +2038 -2038
  81. package/src/programmers/ApplicationProgrammer.ts +48 -48
  82. package/src/programmers/AssertCloneProgrammer.ts +68 -68
  83. package/src/programmers/AssertParseProgrammer.ts +66 -66
  84. package/src/programmers/AssertProgrammer.ts +274 -274
  85. package/src/programmers/AssertPruneProgrammer.ts +73 -73
  86. package/src/programmers/AssertStringifyProgrammer.ts +66 -66
  87. package/src/programmers/CheckerProgrammer.ts +897 -897
  88. package/src/programmers/CloneProgrammer.ts +387 -387
  89. package/src/programmers/FeatureProgrammer.ts +510 -510
  90. package/src/programmers/IsCloneProgrammer.ts +79 -79
  91. package/src/programmers/IsParseProgrammer.ts +72 -72
  92. package/src/programmers/IsProgrammer.ts +223 -223
  93. package/src/programmers/IsPruneProgrammer.ts +83 -83
  94. package/src/programmers/IsStringifyProgrammer.ts +77 -77
  95. package/src/programmers/LiteralsProgrammer.ts +65 -65
  96. package/src/programmers/PruneProgrammer.ts +348 -348
  97. package/src/programmers/RandomProgrammer.ts +444 -444
  98. package/src/programmers/StringifyProgrammer.ts +758 -758
  99. package/src/programmers/TypiaProgrammer.ts +141 -141
  100. package/src/programmers/ValidateCloneProgrammer.ts +93 -93
  101. package/src/programmers/ValidateParseProgrammer.ts +78 -78
  102. package/src/programmers/ValidateProgrammer.ts +317 -317
  103. package/src/programmers/ValidatePruneProgrammer.ts +86 -86
  104. package/src/programmers/ValidateStringifyProgrammer.ts +93 -93
  105. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  106. package/src/programmers/helpers/CloneJoiner.ts +138 -138
  107. package/src/programmers/helpers/FunctionImporeter.ts +56 -56
  108. package/src/programmers/helpers/ICheckEntry.ts +12 -12
  109. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  110. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  111. package/src/programmers/helpers/PruneJoiner.ts +156 -156
  112. package/src/programmers/helpers/RandomJoiner.ts +165 -165
  113. package/src/programmers/helpers/RandomRanger.ts +218 -218
  114. package/src/programmers/helpers/StringifyJoinder.ts +118 -118
  115. package/src/programmers/helpers/StringifyPredicator.ts +12 -12
  116. package/src/programmers/helpers/UnionExplorer.ts +281 -281
  117. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  118. package/src/programmers/helpers/disable_function_importer_declare.ts +21 -21
  119. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  120. package/src/programmers/internal/application_array.ts +32 -32
  121. package/src/programmers/internal/application_boolean.ts +15 -15
  122. package/src/programmers/internal/application_constant.ts +26 -26
  123. package/src/programmers/internal/application_default.ts +17 -17
  124. package/src/programmers/internal/application_default_string.ts +33 -33
  125. package/src/programmers/internal/application_native.ts +36 -36
  126. package/src/programmers/internal/application_number.ts +71 -71
  127. package/src/programmers/internal/application_object.ts +162 -162
  128. package/src/programmers/internal/application_schema.ts +198 -198
  129. package/src/programmers/internal/application_string.ts +44 -44
  130. package/src/programmers/internal/application_templates.ts +25 -25
  131. package/src/programmers/internal/application_tuple.ts +27 -27
  132. package/src/programmers/internal/check_array.ts +31 -31
  133. package/src/programmers/internal/check_array_length.ts +35 -35
  134. package/src/programmers/internal/check_bigint.ts +95 -95
  135. package/src/programmers/internal/check_custom.ts +32 -32
  136. package/src/programmers/internal/check_dynamic_properties.ts +198 -198
  137. package/src/programmers/internal/check_everything.ts +28 -28
  138. package/src/programmers/internal/check_native.ts +22 -22
  139. package/src/programmers/internal/check_number.ts +177 -177
  140. package/src/programmers/internal/check_object.ts +65 -65
  141. package/src/programmers/internal/check_string.ts +27 -27
  142. package/src/programmers/internal/check_string_tags.ts +68 -68
  143. package/src/programmers/internal/check_template.ts +57 -57
  144. package/src/programmers/internal/check_union_array_like.ts +273 -273
  145. package/src/programmers/internal/check_union_tuple.ts +34 -34
  146. package/src/programmers/internal/decode_union_object.ts +75 -75
  147. package/src/programmers/internal/feature_object_entries.ts +64 -64
  148. package/src/programmers/internal/get_comment_tags.ts +23 -23
  149. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  150. package/src/programmers/internal/prune_object_properties.ts +63 -63
  151. package/src/programmers/internal/random_custom.ts +30 -30
  152. package/src/programmers/internal/stringify_dynamic_properties.ts +173 -173
  153. package/src/programmers/internal/stringify_native.ts +7 -7
  154. package/src/programmers/internal/stringify_regular_properties.ts +89 -89
  155. package/src/programmers/internal/template_to_pattern.ts +15 -15
  156. package/src/schemas/IJsonApplication.ts +13 -13
  157. package/src/schemas/IJsonComponents.ts +33 -33
  158. package/src/schemas/IJsonSchema.ts +134 -134
  159. package/src/transform.ts +39 -39
  160. package/src/transformers/CallExpressionTransformer.ts +183 -183
  161. package/src/transformers/FileTransformer.ts +50 -50
  162. package/src/transformers/IProject.ts +18 -18
  163. package/src/transformers/ITransformOptions.ts +62 -62
  164. package/src/transformers/ImportTransformer.ts +74 -74
  165. package/src/transformers/NodeTransformer.ts +13 -13
  166. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +107 -107
  167. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  168. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  169. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  170. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  171. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  172. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  173. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  174. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  175. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  176. package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +43 -43
  177. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  178. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  179. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  180. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  181. package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +31 -31
  182. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +56 -56
  183. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  184. package/src/transformers/features/miscellaneous/RandomTransformer.ts +46 -46
  185. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  186. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  187. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  188. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  189. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  190. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  191. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  192. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  193. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  194. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +12 -12
  195. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  196. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  197. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +12 -12
  198. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  199. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  200. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  201. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  202. package/src/transformers/features/validators/CreateAssertTransformer.ts +13 -13
  203. package/src/transformers/features/validators/CreateIsTransformer.ts +11 -11
  204. package/src/transformers/features/validators/CreateValidateTransformer.ts +13 -13
  205. package/src/transformers/features/validators/IsTransformer.ts +11 -11
  206. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  207. package/src/transformers/internal/GenericTransformer.ts +101 -101
  208. package/src/typings/Atomic.ts +17 -17
  209. package/src/typings/ClassProperties.ts +5 -5
  210. package/src/typings/Customizable.ts +5 -5
  211. package/src/typings/OmitNever.ts +3 -3
  212. package/src/typings/SpecialFields.ts +3 -3
  213. package/src/typings/Writable.ts +11 -11
  214. package/src/utils/ArrayUtil.ts +44 -44
  215. package/src/utils/Escaper.ts +45 -45
  216. package/src/utils/MapUtil.ts +12 -12
  217. package/src/utils/PatternUtil.ts +30 -30
  218. package/src/utils/RandomGenerator.ts +81 -81
  219. package/src/utils/Singleton.ts +17 -17
  220. package/src/utils/TsNodeUtil.ts +17 -17
  221. package/src/utils/TsSymbolUtil.ts +153 -152
  222. package/src/utils/TsTypeUtil.ts +38 -38
@@ -1,510 +1,510 @@
1
- import { JSDocTagInfo } from "typescript";
2
- import type ts from "typescript/lib/tsclibrary";
3
-
4
- import { IdentifierFactory } from "../factories/IdentifierFactory";
5
- import { MetadataCollection } from "../factories/MetadataCollection";
6
- import { StatementFactory } from "../factories/StatementFactory";
7
- import { TypeFactory } from "../factories/TypeFactory";
8
- import { ValueFactory } from "../factories/ValueFactory";
9
-
10
- import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
11
- import { IMetadataTag } from "../metadata/IMetadataTag";
12
- import { Metadata } from "../metadata/Metadata";
13
- import { MetadataObject } from "../metadata/MetadataObject";
14
-
15
- import { IProject } from "../transformers/IProject";
16
-
17
- import { CheckerProgrammer } from "./CheckerProgrammer";
18
- import { FunctionImporter } from "./helpers/FunctionImporeter";
19
- import { IExpressionEntry } from "./helpers/IExpressionEntry";
20
- import { UnionExplorer } from "./helpers/UnionExplorer";
21
- import { feature_object_entries } from "./internal/feature_object_entries";
22
-
23
- export namespace FeatureProgrammer {
24
- /* -----------------------------------------------------------
25
- PARAMETERS
26
- ----------------------------------------------------------- */
27
- export interface IConfig<Output extends ts.ConciseBody = ts.ConciseBody> {
28
- types: IConfig.ITypes;
29
-
30
- /**
31
- * Prefix name of functions for specific object types.
32
- */
33
- functors: string;
34
-
35
- /**
36
- * Prefix name of functions for union object types.
37
- */
38
- unioners: string;
39
-
40
- /**
41
- * Whether to archive access path or not.
42
- */
43
- path: boolean;
44
-
45
- /**
46
- * Whether to trace exception or not.
47
- */
48
- trace: boolean;
49
-
50
- addition?(collection: MetadataCollection): ts.Statement[];
51
-
52
- /**
53
- * Initializer of metadata.
54
- */
55
- initializer: (
56
- project: IProject,
57
- ) => (type: ts.Type) => [MetadataCollection, Metadata];
58
-
59
- /**
60
- * Decoder, station of every types.
61
- */
62
- decoder: Decoder<Metadata, Output>;
63
-
64
- /**
65
- * Object configurator.
66
- */
67
- objector: IConfig.IObjector;
68
-
69
- /**
70
- * Generator of functions for object types.
71
- */
72
- generator?: Partial<IConfig.IGenerator>;
73
- }
74
- export namespace IConfig {
75
- export interface ITypes {
76
- input: (type: ts.Type, name?: string) => ts.TypeNode;
77
- output: (type: ts.Type, name?: string) => ts.TypeNode;
78
- }
79
-
80
- export interface IObjector {
81
- /**
82
- * Type checker when union object type comes.
83
- */
84
- checker: Decoder<Metadata, ts.Expression>;
85
-
86
- /**
87
- * Decoder, function call expression generator of specific typed objects.
88
- */
89
- decoder: Decoder<MetadataObject, ts.Expression>;
90
-
91
- /**
92
- * Joiner of expressions from properties.
93
- */
94
- joiner(
95
- input: ts.Expression,
96
- entries: IExpressionEntry[],
97
- parent: MetadataObject,
98
- ): ts.ConciseBody;
99
-
100
- /**
101
- * Union type specificator.
102
- *
103
- * Expression of an algorithm specifying object type and calling
104
- * the `decoder` function of the specified object type.
105
- */
106
- unionizer: Decoder<MetadataObject[], ts.Expression>;
107
-
108
- /**
109
- * Handler of union type specification failure.
110
- *
111
- * @param value Expression of input parameter
112
- * @param expected Expected type name
113
- * @param explore Exploration info
114
- * @returns Statement of failure
115
- */
116
- failure(
117
- value: ts.Expression,
118
- expected: string,
119
- explore?: IExplore,
120
- ): ts.Statement;
121
-
122
- /**
123
- * Transformer of type checking expression by discrimination.
124
- *
125
- * When an object type has been specified by a discrimination without full
126
- * iteration, the `unionizer` will decode the object instance after
127
- * the last type checking.
128
- *
129
- * In such circumtance, you can transform the last type checking function.
130
- *
131
- * @param exp Current expression about type checking
132
- * @returns Transformed expression
133
- * @deprecated
134
- */
135
- is?(exp: ts.Expression): ts.Expression;
136
-
137
- /**
138
- * Transformer of non-undefined type checking by discrimination.
139
- *
140
- * When specifying an union type of objects, `typia` tries to find
141
- * descrimination way just by checking only one property type.
142
- * If succeeded to find the discrimination way, `typia` will check the target
143
- * property type and in the checking, non-undefined type checking would be
144
- * done.
145
- *
146
- * In such process, you can transform the non-undefined type checking.
147
- *
148
- * @param exp
149
- * @returns Transformed expression
150
- * @deprecated
151
- */
152
- required?(exp: ts.Expression): ts.Expression;
153
-
154
- /**
155
- * Conditon wrapper when unable to specify any object type.
156
- *
157
- * When failed to specify an object type through discrimination, full
158
- * iteration type checking would be happend. In such circumstance, you
159
- * can wrap the condition with additional function.
160
- *
161
- * @param condition Current condition
162
- * @returns A function wrapped current condition
163
- */
164
- full?: (
165
- condition: ts.Expression,
166
- ) => (
167
- input: ts.Expression,
168
- expected: string,
169
- explore: IExplore,
170
- ) => ts.Expression;
171
-
172
- /**
173
- * Return type.
174
- */
175
- type?: ts.TypeNode;
176
- }
177
- export interface IGenerator {
178
- /**
179
- *
180
- * @param col
181
- */
182
- functors(col: MetadataCollection): ts.VariableStatement[];
183
-
184
- /**
185
- *
186
- * @param col
187
- */
188
- unioners(col: MetadataCollection): ts.VariableStatement[];
189
- }
190
- }
191
-
192
- export interface IExplore {
193
- tracable: boolean;
194
- source: "top" | "object";
195
- from: "top" | "array" | "object";
196
- postfix: string;
197
- start?: number;
198
- }
199
-
200
- export interface Decoder<
201
- T,
202
- Output extends ts.ConciseBody = ts.ConciseBody,
203
- > {
204
- (
205
- input: ts.Expression,
206
- target: T,
207
- explore: IExplore,
208
- metaTags: IMetadataTag[],
209
- jsDocTags: JSDocTagInfo[],
210
- ): Output;
211
- }
212
-
213
- /* -----------------------------------------------------------
214
- GENERATORS
215
- ----------------------------------------------------------- */
216
- export const analyze =
217
- (p: IProject) =>
218
- (config: IConfig) =>
219
- (importer: FunctionImporter) =>
220
- (type: ts.Type, name?: string) => {
221
- const [collection, meta] = config.initializer(p)(type);
222
-
223
- // ITERATE OVER ALL METADATA
224
- const output: ts.ConciseBody = config.decoder(
225
- ValueFactory.INPUT(p.tsc)(),
226
- meta,
227
- {
228
- tracable: config.path || config.trace,
229
- source: "top",
230
- from: "top",
231
- postfix: '""',
232
- },
233
- [],
234
- [],
235
- );
236
-
237
- // RETURNS THE OPTIMAL ARROW FUNCTION
238
- const functors: ts.VariableStatement[] = (
239
- config.generator?.functors ??
240
- write_functors(p.tsc)(config)(importer)
241
- )(collection);
242
- const unioners: ts.VariableStatement[] = (
243
- config.generator?.unioners ??
244
- write_unioners(p.tsc)(config)(importer)
245
- )(collection);
246
- const added: ts.Statement[] = (config.addition ?? (() => []))(
247
- collection,
248
- );
249
-
250
- return p.tsc.factory.createArrowFunction(
251
- undefined,
252
- undefined,
253
- PARAMETERS(p.tsc)(config)(config.types.input(type, name))(
254
- ValueFactory.INPUT(p.tsc)(),
255
- ),
256
- config.types.output(type, name),
257
- undefined,
258
- p.tsc.factory.createBlock(
259
- [
260
- ...added,
261
- ...functors.filter((_, i) =>
262
- importer.hasLocal(`${config.functors}${i}`),
263
- ),
264
- ...unioners.filter((_, i) =>
265
- importer.hasLocal(`${config.unioners}${i}`),
266
- ),
267
- ...(p.tsc.isBlock(output)
268
- ? output.statements
269
- : [p.tsc.factory.createReturnStatement(output)]),
270
- ],
271
- true,
272
- ),
273
- );
274
- };
275
-
276
- export const write_functors =
277
- (tsc: typeof ts) =>
278
- (config: IConfig) =>
279
- (importer: FunctionImporter) =>
280
- (collection: MetadataCollection) =>
281
- collection
282
- .objects()
283
- .map((obj, i) =>
284
- StatementFactory.constant(tsc)(
285
- `${config.functors}${i}`,
286
- write_object(tsc)(config)(importer)(obj),
287
- ),
288
- );
289
-
290
- export const write_unioners =
291
- (tsc: typeof ts) =>
292
- (config: IConfig) =>
293
- (importer: FunctionImporter) =>
294
- (collection: MetadataCollection) =>
295
- collection
296
- .unions()
297
- .map((union, i) =>
298
- StatementFactory.constant(tsc)(
299
- importer.useLocal(`${config.unioners}${i}`),
300
- write_union(tsc)(config)(union),
301
- ),
302
- );
303
-
304
- const write_object =
305
- (tsc: typeof ts) =>
306
- (config: IConfig) =>
307
- (importer: FunctionImporter) =>
308
- (obj: MetadataObject) =>
309
- tsc.factory.createArrowFunction(
310
- undefined,
311
- undefined,
312
- PARAMETERS(tsc)(config)(TypeFactory.keyword(tsc)("any"))(
313
- ValueFactory.INPUT(tsc)(),
314
- ),
315
- config.objector.type ?? TypeFactory.keyword(tsc)("any"),
316
- undefined,
317
- config.objector.joiner(
318
- tsc.factory.createIdentifier("input"),
319
- feature_object_entries(tsc)(config)(importer)(obj)(
320
- tsc.factory.createIdentifier("input"),
321
- ),
322
- obj,
323
- ),
324
- );
325
-
326
- const write_union = (tsc: typeof ts) => (config: IConfig) => {
327
- const explorer = UnionExplorer.object(tsc)(config);
328
- const input = ValueFactory.INPUT(tsc)();
329
-
330
- return (meta: MetadataObject[]) =>
331
- tsc.factory.createArrowFunction(
332
- undefined,
333
- undefined,
334
- PARAMETERS(tsc)(config)(TypeFactory.keyword(tsc)("any"))(
335
- ValueFactory.INPUT(tsc)(),
336
- ),
337
- TypeFactory.keyword(tsc)("any"),
338
- undefined,
339
- explorer(
340
- input,
341
- meta,
342
- {
343
- tracable: config.path || config.trace,
344
- source: "object",
345
- from: "object",
346
- postfix: "",
347
- },
348
- [],
349
- [],
350
- ),
351
- );
352
- };
353
-
354
- /* -----------------------------------------------------------
355
- DECODERS
356
- ----------------------------------------------------------- */
357
- export const decode_array =
358
- (tsc: typeof ts) =>
359
- (config: Pick<IConfig, "trace" | "path" | "decoder">) =>
360
- (importer: FunctionImporter) =>
361
- (
362
- combiner: (
363
- input: ts.Expression,
364
- arrow: ts.ArrowFunction,
365
- metaTags: IMetadataTag[],
366
- jsDocTags: JSDocTagInfo[],
367
- ) => ts.Expression,
368
- ) => {
369
- const rand: string = importer.increment().toString();
370
- const tail =
371
- config.path || config.trace
372
- ? [
373
- IdentifierFactory.parameter(tsc)(
374
- "_index" + rand,
375
- TypeFactory.keyword(tsc)("number"),
376
- ),
377
- ]
378
- : [];
379
-
380
- return (
381
- input: ts.Expression,
382
- meta: Metadata,
383
- explore: IExplore,
384
- metaTags: IMetadataTag[],
385
- jsDocTags: IJsDocTagInfo[],
386
- ) => {
387
- const arrow: ts.ArrowFunction = tsc.factory.createArrowFunction(
388
- undefined,
389
- undefined,
390
- [
391
- IdentifierFactory.parameter(tsc)(
392
- "elem",
393
- TypeFactory.keyword(tsc)("any"),
394
- ),
395
- ...tail,
396
- ],
397
- undefined,
398
- undefined,
399
- config.decoder(
400
- ValueFactory.INPUT(tsc)("elem"),
401
- meta,
402
- {
403
- tracable: explore.tracable,
404
- source: explore.source,
405
- from: "array",
406
- postfix: INDEX_SYMBOL(explore.start ?? null)(
407
- explore.postfix,
408
- )(rand),
409
- },
410
- metaTags,
411
- jsDocTags,
412
- ),
413
- );
414
- return combiner(input, arrow, metaTags, jsDocTags);
415
- };
416
- };
417
-
418
- export const decode_object =
419
- (tsc: typeof ts) =>
420
- (config: Pick<IConfig, "trace" | "path" | "functors">) =>
421
- (importer: FunctionImporter) =>
422
- (input: ts.Expression, obj: MetadataObject, explore: IExplore) =>
423
- tsc.factory.createCallExpression(
424
- tsc.factory.createIdentifier(
425
- importer.useLocal(`${config.functors}${obj.index}`),
426
- ),
427
- undefined,
428
- get_object_arguments(tsc)(config)(explore)(input),
429
- );
430
-
431
- export const get_object_arguments =
432
- (tsc: typeof ts) =>
433
- (config: Pick<IConfig, "path" | "trace">) =>
434
- (explore: FeatureProgrammer.IExplore) => {
435
- const tail: ts.Expression[] =
436
- config.path === false && config.trace === false
437
- ? []
438
- : config.path === true && config.trace === true
439
- ? [
440
- tsc.factory.createIdentifier(
441
- explore.postfix
442
- ? `_path + ${explore.postfix}`
443
- : "_path",
444
- ),
445
- explore.source === "object"
446
- ? tsc.factory.createIdentifier(
447
- `${explore.tracable} && _exceptionable`,
448
- )
449
- : explore.tracable
450
- ? tsc.factory.createTrue()
451
- : tsc.factory.createFalse(),
452
- ]
453
- : config.path === true
454
- ? [
455
- tsc.factory.createIdentifier(
456
- explore.postfix
457
- ? `_path + ${explore.postfix}`
458
- : "_path",
459
- ),
460
- ]
461
- : [
462
- explore.source === "object"
463
- ? tsc.factory.createIdentifier(
464
- `${explore.tracable} && _exceptionable`,
465
- )
466
- : explore.tracable
467
- ? tsc.factory.createTrue()
468
- : tsc.factory.createFalse(),
469
- ];
470
- return (input: ts.Expression) => [input, ...tail];
471
- };
472
- }
473
-
474
- const INDEX_SYMBOL =
475
- (start: number | null) => (prev: string) => (rand: string) => {
476
- const tail: string =
477
- start !== null
478
- ? `"[" + (${start} + _index${rand}) + "]"`
479
- : `"[" + _index${rand} + "]"`;
480
- if (prev === "") return tail;
481
- else if (prev[prev.length - 1] === `"`)
482
- return prev.substring(0, prev.length - 1) + tail.substring(1);
483
- return prev + ` + ${tail}`;
484
- };
485
-
486
- const PARAMETERS =
487
- (tsc: typeof ts) =>
488
- (props: Pick<CheckerProgrammer.IConfig, "path" | "trace">) =>
489
- (type: ts.TypeNode) => {
490
- const tail: ts.ParameterDeclaration[] = [];
491
- if (props.path)
492
- tail.push(
493
- IdentifierFactory.parameter(tsc)(
494
- "_path",
495
- TypeFactory.keyword(tsc)("string"),
496
- ),
497
- );
498
- if (props.trace)
499
- tail.push(
500
- IdentifierFactory.parameter(tsc)(
501
- "_exceptionable",
502
- TypeFactory.keyword(tsc)("boolean"),
503
- tsc.factory.createTrue(),
504
- ),
505
- );
506
- return (input: ts.Identifier) => [
507
- IdentifierFactory.parameter(tsc)(input, type),
508
- ...tail,
509
- ];
510
- };
1
+ import { JSDocTagInfo } from "typescript";
2
+ import type ts from "typescript/lib/tsclibrary";
3
+
4
+ import { IdentifierFactory } from "../factories/IdentifierFactory";
5
+ import { MetadataCollection } from "../factories/MetadataCollection";
6
+ import { StatementFactory } from "../factories/StatementFactory";
7
+ import { TypeFactory } from "../factories/TypeFactory";
8
+ import { ValueFactory } from "../factories/ValueFactory";
9
+
10
+ import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
11
+ import { IMetadataTag } from "../metadata/IMetadataTag";
12
+ import { Metadata } from "../metadata/Metadata";
13
+ import { MetadataObject } from "../metadata/MetadataObject";
14
+
15
+ import { IProject } from "../transformers/IProject";
16
+
17
+ import { CheckerProgrammer } from "./CheckerProgrammer";
18
+ import { FunctionImporter } from "./helpers/FunctionImporeter";
19
+ import { IExpressionEntry } from "./helpers/IExpressionEntry";
20
+ import { UnionExplorer } from "./helpers/UnionExplorer";
21
+ import { feature_object_entries } from "./internal/feature_object_entries";
22
+
23
+ export namespace FeatureProgrammer {
24
+ /* -----------------------------------------------------------
25
+ PARAMETERS
26
+ ----------------------------------------------------------- */
27
+ export interface IConfig<Output extends ts.ConciseBody = ts.ConciseBody> {
28
+ types: IConfig.ITypes;
29
+
30
+ /**
31
+ * Prefix name of functions for specific object types.
32
+ */
33
+ functors: string;
34
+
35
+ /**
36
+ * Prefix name of functions for union object types.
37
+ */
38
+ unioners: string;
39
+
40
+ /**
41
+ * Whether to archive access path or not.
42
+ */
43
+ path: boolean;
44
+
45
+ /**
46
+ * Whether to trace exception or not.
47
+ */
48
+ trace: boolean;
49
+
50
+ addition?(collection: MetadataCollection): ts.Statement[];
51
+
52
+ /**
53
+ * Initializer of metadata.
54
+ */
55
+ initializer: (
56
+ project: IProject,
57
+ ) => (type: ts.Type) => [MetadataCollection, Metadata];
58
+
59
+ /**
60
+ * Decoder, station of every types.
61
+ */
62
+ decoder: Decoder<Metadata, Output>;
63
+
64
+ /**
65
+ * Object configurator.
66
+ */
67
+ objector: IConfig.IObjector;
68
+
69
+ /**
70
+ * Generator of functions for object types.
71
+ */
72
+ generator?: Partial<IConfig.IGenerator>;
73
+ }
74
+ export namespace IConfig {
75
+ export interface ITypes {
76
+ input: (type: ts.Type, name?: string) => ts.TypeNode;
77
+ output: (type: ts.Type, name?: string) => ts.TypeNode;
78
+ }
79
+
80
+ export interface IObjector {
81
+ /**
82
+ * Type checker when union object type comes.
83
+ */
84
+ checker: Decoder<Metadata, ts.Expression>;
85
+
86
+ /**
87
+ * Decoder, function call expression generator of specific typed objects.
88
+ */
89
+ decoder: Decoder<MetadataObject, ts.Expression>;
90
+
91
+ /**
92
+ * Joiner of expressions from properties.
93
+ */
94
+ joiner(
95
+ input: ts.Expression,
96
+ entries: IExpressionEntry[],
97
+ parent: MetadataObject,
98
+ ): ts.ConciseBody;
99
+
100
+ /**
101
+ * Union type specificator.
102
+ *
103
+ * Expression of an algorithm specifying object type and calling
104
+ * the `decoder` function of the specified object type.
105
+ */
106
+ unionizer: Decoder<MetadataObject[], ts.Expression>;
107
+
108
+ /**
109
+ * Handler of union type specification failure.
110
+ *
111
+ * @param value Expression of input parameter
112
+ * @param expected Expected type name
113
+ * @param explore Exploration info
114
+ * @returns Statement of failure
115
+ */
116
+ failure(
117
+ value: ts.Expression,
118
+ expected: string,
119
+ explore?: IExplore,
120
+ ): ts.Statement;
121
+
122
+ /**
123
+ * Transformer of type checking expression by discrimination.
124
+ *
125
+ * When an object type has been specified by a discrimination without full
126
+ * iteration, the `unionizer` will decode the object instance after
127
+ * the last type checking.
128
+ *
129
+ * In such circumtance, you can transform the last type checking function.
130
+ *
131
+ * @param exp Current expression about type checking
132
+ * @returns Transformed expression
133
+ * @deprecated
134
+ */
135
+ is?(exp: ts.Expression): ts.Expression;
136
+
137
+ /**
138
+ * Transformer of non-undefined type checking by discrimination.
139
+ *
140
+ * When specifying an union type of objects, `typia` tries to find
141
+ * descrimination way just by checking only one property type.
142
+ * If succeeded to find the discrimination way, `typia` will check the target
143
+ * property type and in the checking, non-undefined type checking would be
144
+ * done.
145
+ *
146
+ * In such process, you can transform the non-undefined type checking.
147
+ *
148
+ * @param exp
149
+ * @returns Transformed expression
150
+ * @deprecated
151
+ */
152
+ required?(exp: ts.Expression): ts.Expression;
153
+
154
+ /**
155
+ * Conditon wrapper when unable to specify any object type.
156
+ *
157
+ * When failed to specify an object type through discrimination, full
158
+ * iteration type checking would be happend. In such circumstance, you
159
+ * can wrap the condition with additional function.
160
+ *
161
+ * @param condition Current condition
162
+ * @returns A function wrapped current condition
163
+ */
164
+ full?: (
165
+ condition: ts.Expression,
166
+ ) => (
167
+ input: ts.Expression,
168
+ expected: string,
169
+ explore: IExplore,
170
+ ) => ts.Expression;
171
+
172
+ /**
173
+ * Return type.
174
+ */
175
+ type?: ts.TypeNode;
176
+ }
177
+ export interface IGenerator {
178
+ /**
179
+ *
180
+ * @param col
181
+ */
182
+ functors(col: MetadataCollection): ts.VariableStatement[];
183
+
184
+ /**
185
+ *
186
+ * @param col
187
+ */
188
+ unioners(col: MetadataCollection): ts.VariableStatement[];
189
+ }
190
+ }
191
+
192
+ export interface IExplore {
193
+ tracable: boolean;
194
+ source: "top" | "object";
195
+ from: "top" | "array" | "object";
196
+ postfix: string;
197
+ start?: number;
198
+ }
199
+
200
+ export interface Decoder<
201
+ T,
202
+ Output extends ts.ConciseBody = ts.ConciseBody,
203
+ > {
204
+ (
205
+ input: ts.Expression,
206
+ target: T,
207
+ explore: IExplore,
208
+ metaTags: IMetadataTag[],
209
+ jsDocTags: JSDocTagInfo[],
210
+ ): Output;
211
+ }
212
+
213
+ /* -----------------------------------------------------------
214
+ GENERATORS
215
+ ----------------------------------------------------------- */
216
+ export const analyze =
217
+ (p: IProject) =>
218
+ (config: IConfig) =>
219
+ (importer: FunctionImporter) =>
220
+ (type: ts.Type, name?: string) => {
221
+ const [collection, meta] = config.initializer(p)(type);
222
+
223
+ // ITERATE OVER ALL METADATA
224
+ const output: ts.ConciseBody = config.decoder(
225
+ ValueFactory.INPUT(p.tsc)(),
226
+ meta,
227
+ {
228
+ tracable: config.path || config.trace,
229
+ source: "top",
230
+ from: "top",
231
+ postfix: '""',
232
+ },
233
+ [],
234
+ [],
235
+ );
236
+
237
+ // RETURNS THE OPTIMAL ARROW FUNCTION
238
+ const functors: ts.VariableStatement[] = (
239
+ config.generator?.functors ??
240
+ write_functors(p.tsc)(config)(importer)
241
+ )(collection);
242
+ const unioners: ts.VariableStatement[] = (
243
+ config.generator?.unioners ??
244
+ write_unioners(p.tsc)(config)(importer)
245
+ )(collection);
246
+ const added: ts.Statement[] = (config.addition ?? (() => []))(
247
+ collection,
248
+ );
249
+
250
+ return p.tsc.factory.createArrowFunction(
251
+ undefined,
252
+ undefined,
253
+ PARAMETERS(p.tsc)(config)(config.types.input(type, name))(
254
+ ValueFactory.INPUT(p.tsc)(),
255
+ ),
256
+ config.types.output(type, name),
257
+ undefined,
258
+ p.tsc.factory.createBlock(
259
+ [
260
+ ...added,
261
+ ...functors.filter((_, i) =>
262
+ importer.hasLocal(`${config.functors}${i}`),
263
+ ),
264
+ ...unioners.filter((_, i) =>
265
+ importer.hasLocal(`${config.unioners}${i}`),
266
+ ),
267
+ ...(p.tsc.isBlock(output)
268
+ ? output.statements
269
+ : [p.tsc.factory.createReturnStatement(output)]),
270
+ ],
271
+ true,
272
+ ),
273
+ );
274
+ };
275
+
276
+ export const write_functors =
277
+ (tsc: typeof ts) =>
278
+ (config: IConfig) =>
279
+ (importer: FunctionImporter) =>
280
+ (collection: MetadataCollection) =>
281
+ collection
282
+ .objects()
283
+ .map((obj, i) =>
284
+ StatementFactory.constant(tsc)(
285
+ `${config.functors}${i}`,
286
+ write_object(tsc)(config)(importer)(obj),
287
+ ),
288
+ );
289
+
290
+ export const write_unioners =
291
+ (tsc: typeof ts) =>
292
+ (config: IConfig) =>
293
+ (importer: FunctionImporter) =>
294
+ (collection: MetadataCollection) =>
295
+ collection
296
+ .unions()
297
+ .map((union, i) =>
298
+ StatementFactory.constant(tsc)(
299
+ importer.useLocal(`${config.unioners}${i}`),
300
+ write_union(tsc)(config)(union),
301
+ ),
302
+ );
303
+
304
+ const write_object =
305
+ (tsc: typeof ts) =>
306
+ (config: IConfig) =>
307
+ (importer: FunctionImporter) =>
308
+ (obj: MetadataObject) =>
309
+ tsc.factory.createArrowFunction(
310
+ undefined,
311
+ undefined,
312
+ PARAMETERS(tsc)(config)(TypeFactory.keyword(tsc)("any"))(
313
+ ValueFactory.INPUT(tsc)(),
314
+ ),
315
+ config.objector.type ?? TypeFactory.keyword(tsc)("any"),
316
+ undefined,
317
+ config.objector.joiner(
318
+ tsc.factory.createIdentifier("input"),
319
+ feature_object_entries(tsc)(config)(importer)(obj)(
320
+ tsc.factory.createIdentifier("input"),
321
+ ),
322
+ obj,
323
+ ),
324
+ );
325
+
326
+ const write_union = (tsc: typeof ts) => (config: IConfig) => {
327
+ const explorer = UnionExplorer.object(tsc)(config);
328
+ const input = ValueFactory.INPUT(tsc)();
329
+
330
+ return (meta: MetadataObject[]) =>
331
+ tsc.factory.createArrowFunction(
332
+ undefined,
333
+ undefined,
334
+ PARAMETERS(tsc)(config)(TypeFactory.keyword(tsc)("any"))(
335
+ ValueFactory.INPUT(tsc)(),
336
+ ),
337
+ TypeFactory.keyword(tsc)("any"),
338
+ undefined,
339
+ explorer(
340
+ input,
341
+ meta,
342
+ {
343
+ tracable: config.path || config.trace,
344
+ source: "object",
345
+ from: "object",
346
+ postfix: "",
347
+ },
348
+ [],
349
+ [],
350
+ ),
351
+ );
352
+ };
353
+
354
+ /* -----------------------------------------------------------
355
+ DECODERS
356
+ ----------------------------------------------------------- */
357
+ export const decode_array =
358
+ (tsc: typeof ts) =>
359
+ (config: Pick<IConfig, "trace" | "path" | "decoder">) =>
360
+ (importer: FunctionImporter) =>
361
+ (
362
+ combiner: (
363
+ input: ts.Expression,
364
+ arrow: ts.ArrowFunction,
365
+ metaTags: IMetadataTag[],
366
+ jsDocTags: JSDocTagInfo[],
367
+ ) => ts.Expression,
368
+ ) => {
369
+ const rand: string = importer.increment().toString();
370
+ const tail =
371
+ config.path || config.trace
372
+ ? [
373
+ IdentifierFactory.parameter(tsc)(
374
+ "_index" + rand,
375
+ TypeFactory.keyword(tsc)("number"),
376
+ ),
377
+ ]
378
+ : [];
379
+
380
+ return (
381
+ input: ts.Expression,
382
+ meta: Metadata,
383
+ explore: IExplore,
384
+ metaTags: IMetadataTag[],
385
+ jsDocTags: IJsDocTagInfo[],
386
+ ) => {
387
+ const arrow: ts.ArrowFunction = tsc.factory.createArrowFunction(
388
+ undefined,
389
+ undefined,
390
+ [
391
+ IdentifierFactory.parameter(tsc)(
392
+ "elem",
393
+ TypeFactory.keyword(tsc)("any"),
394
+ ),
395
+ ...tail,
396
+ ],
397
+ undefined,
398
+ undefined,
399
+ config.decoder(
400
+ ValueFactory.INPUT(tsc)("elem"),
401
+ meta,
402
+ {
403
+ tracable: explore.tracable,
404
+ source: explore.source,
405
+ from: "array",
406
+ postfix: INDEX_SYMBOL(explore.start ?? null)(
407
+ explore.postfix,
408
+ )(rand),
409
+ },
410
+ metaTags,
411
+ jsDocTags,
412
+ ),
413
+ );
414
+ return combiner(input, arrow, metaTags, jsDocTags);
415
+ };
416
+ };
417
+
418
+ export const decode_object =
419
+ (tsc: typeof ts) =>
420
+ (config: Pick<IConfig, "trace" | "path" | "functors">) =>
421
+ (importer: FunctionImporter) =>
422
+ (input: ts.Expression, obj: MetadataObject, explore: IExplore) =>
423
+ tsc.factory.createCallExpression(
424
+ tsc.factory.createIdentifier(
425
+ importer.useLocal(`${config.functors}${obj.index}`),
426
+ ),
427
+ undefined,
428
+ get_object_arguments(tsc)(config)(explore)(input),
429
+ );
430
+
431
+ export const get_object_arguments =
432
+ (tsc: typeof ts) =>
433
+ (config: Pick<IConfig, "path" | "trace">) =>
434
+ (explore: FeatureProgrammer.IExplore) => {
435
+ const tail: ts.Expression[] =
436
+ config.path === false && config.trace === false
437
+ ? []
438
+ : config.path === true && config.trace === true
439
+ ? [
440
+ tsc.factory.createIdentifier(
441
+ explore.postfix
442
+ ? `_path + ${explore.postfix}`
443
+ : "_path",
444
+ ),
445
+ explore.source === "object"
446
+ ? tsc.factory.createIdentifier(
447
+ `${explore.tracable} && _exceptionable`,
448
+ )
449
+ : explore.tracable
450
+ ? tsc.factory.createTrue()
451
+ : tsc.factory.createFalse(),
452
+ ]
453
+ : config.path === true
454
+ ? [
455
+ tsc.factory.createIdentifier(
456
+ explore.postfix
457
+ ? `_path + ${explore.postfix}`
458
+ : "_path",
459
+ ),
460
+ ]
461
+ : [
462
+ explore.source === "object"
463
+ ? tsc.factory.createIdentifier(
464
+ `${explore.tracable} && _exceptionable`,
465
+ )
466
+ : explore.tracable
467
+ ? tsc.factory.createTrue()
468
+ : tsc.factory.createFalse(),
469
+ ];
470
+ return (input: ts.Expression) => [input, ...tail];
471
+ };
472
+ }
473
+
474
+ const INDEX_SYMBOL =
475
+ (start: number | null) => (prev: string) => (rand: string) => {
476
+ const tail: string =
477
+ start !== null
478
+ ? `"[" + (${start} + _index${rand}) + "]"`
479
+ : `"[" + _index${rand} + "]"`;
480
+ if (prev === "") return tail;
481
+ else if (prev[prev.length - 1] === `"`)
482
+ return prev.substring(0, prev.length - 1) + tail.substring(1);
483
+ return prev + ` + ${tail}`;
484
+ };
485
+
486
+ const PARAMETERS =
487
+ (tsc: typeof ts) =>
488
+ (props: Pick<CheckerProgrammer.IConfig, "path" | "trace">) =>
489
+ (type: ts.TypeNode) => {
490
+ const tail: ts.ParameterDeclaration[] = [];
491
+ if (props.path)
492
+ tail.push(
493
+ IdentifierFactory.parameter(tsc)(
494
+ "_path",
495
+ TypeFactory.keyword(tsc)("string"),
496
+ ),
497
+ );
498
+ if (props.trace)
499
+ tail.push(
500
+ IdentifierFactory.parameter(tsc)(
501
+ "_exceptionable",
502
+ TypeFactory.keyword(tsc)("boolean"),
503
+ tsc.factory.createTrue(),
504
+ ),
505
+ );
506
+ return (input: ts.Identifier) => [
507
+ IdentifierFactory.parameter(tsc)(input, type),
508
+ ...tail,
509
+ ];
510
+ };