typia 3.8.0-dev.20230415 → 3.8.0-dev.20230417

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 (53) hide show
  1. package/README.md +35 -228
  2. package/lib/factories/TypiaFileFactory.js +9 -4
  3. package/lib/factories/TypiaFileFactory.js.map +1 -1
  4. package/lib/typings/Customizable.d.ts +2 -2
  5. package/lib/utils/RandomGenerator.d.ts +17 -1
  6. package/lib/utils/RandomGenerator.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/IRandomGenerator.ts +33 -33
  9. package/src/executable/TypiaGenerateWizard.ts +85 -85
  10. package/src/executable/TypiaSetupWizard.ts +118 -118
  11. package/src/executable/setup/ArgumentParser.ts +45 -45
  12. package/src/executable/setup/CommandExecutor.ts +8 -8
  13. package/src/executable/setup/FileRetriever.ts +22 -22
  14. package/src/executable/setup/PackageManager.ts +71 -71
  15. package/src/executable/setup/PluginConfigurator.ts +59 -59
  16. package/src/executable/typia.ts +52 -52
  17. package/src/factories/IdentifierFactory.ts +59 -59
  18. package/src/factories/MetadataTagFactory.ts +302 -302
  19. package/src/factories/TypiaFileFactory.ts +12 -3
  20. package/src/metadata/ICommentTag.ts +4 -4
  21. package/src/metadata/Metadata.ts +533 -533
  22. package/src/module.ts +2043 -2043
  23. package/src/programmers/AssertProgrammer.ts +284 -284
  24. package/src/programmers/CheckerProgrammer.ts +920 -920
  25. package/src/programmers/LiteralsProgrammer.ts +65 -65
  26. package/src/programmers/RandomProgrammer.ts +413 -413
  27. package/src/programmers/ValidateProgrammer.ts +317 -317
  28. package/src/programmers/helpers/RandomJoiner.ts +161 -161
  29. package/src/programmers/helpers/RandomRanger.ts +216 -216
  30. package/src/programmers/internal/application_native.ts +32 -32
  31. package/src/programmers/internal/check_array.ts +30 -30
  32. package/src/programmers/internal/check_array_length.ts +35 -35
  33. package/src/programmers/internal/check_custom.ts +33 -33
  34. package/src/programmers/internal/check_number.ts +177 -177
  35. package/src/programmers/internal/check_object.ts +55 -55
  36. package/src/programmers/internal/check_string_tags.ts +67 -67
  37. package/src/programmers/internal/check_template.ts +56 -56
  38. package/src/programmers/internal/check_union_array_like.ts +272 -272
  39. package/src/programmers/internal/feature_object_entries.ts +63 -63
  40. package/src/programmers/internal/get_comment_tags.ts +23 -23
  41. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  42. package/src/programmers/internal/random_custom.ts +30 -30
  43. package/src/programmers/internal/stringify_dynamic_properties.ts +168 -168
  44. package/src/programmers/internal/stringify_regular_properties.ts +84 -84
  45. package/src/transformers/CallExpressionTransformer.ts +174 -174
  46. package/src/transformers/ImportTransformer.ts +66 -66
  47. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +119 -119
  48. package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +41 -41
  49. package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +30 -30
  50. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +54 -54
  51. package/src/transformers/features/miscellaneous/RandomTransformer.ts +46 -46
  52. package/src/typings/Customizable.ts +5 -5
  53. package/src/utils/RandomGenerator.ts +93 -96
@@ -1,63 +1,63 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
-
5
- import { MetadataObject } from "../../metadata/MetadataObject";
6
-
7
- import { Escaper } from "../../utils/Escaper";
8
-
9
- import { FeatureProgrammer } from "../FeatureProgrammer";
10
- import { FunctionImporter } from "../helpers/FunctionImporeter";
11
-
12
- /**
13
- * @internal
14
- */
15
- export const feature_object_entries =
16
- <Output extends ts.ConciseBody>(
17
- config: Pick<
18
- FeatureProgrammer.IConfig<Output>,
19
- "decoder" | "path" | "trace"
20
- >,
21
- ) =>
22
- (importer: FunctionImporter) =>
23
- (obj: MetadataObject) =>
24
- (input: ts.Expression) =>
25
- obj.properties.map((prop) => {
26
- const sole: string | null = prop.key.getSoleLiteral();
27
- const propInput =
28
- sole === null
29
- ? ts.factory.createIdentifier("value")
30
- : Escaper.variable(sole)
31
- ? ts.factory.createPropertyAccessExpression(
32
- input,
33
- ts.factory.createIdentifier(sole),
34
- )
35
- : ts.factory.createElementAccessExpression(
36
- input,
37
- ts.factory.createStringLiteral(sole),
38
- );
39
-
40
- return {
41
- input: propInput,
42
- key: prop.key,
43
- meta: prop.value,
44
- expression: config.decoder(
45
- propInput,
46
- prop.value,
47
- {
48
- tracable: config.path || config.trace,
49
- source: "object",
50
- from: "object",
51
- postfix:
52
- sole !== null
53
- ? IdentifierFactory.postfix(sole)
54
- : (() => {
55
- importer.use("join");
56
- return `$join(key)`;
57
- })(),
58
- },
59
- prop.tags,
60
- prop.jsDocTags,
61
- ),
62
- };
63
- });
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+
5
+ import { MetadataObject } from "../../metadata/MetadataObject";
6
+
7
+ import { Escaper } from "../../utils/Escaper";
8
+
9
+ import { FeatureProgrammer } from "../FeatureProgrammer";
10
+ import { FunctionImporter } from "../helpers/FunctionImporeter";
11
+
12
+ /**
13
+ * @internal
14
+ */
15
+ export const feature_object_entries =
16
+ <Output extends ts.ConciseBody>(
17
+ config: Pick<
18
+ FeatureProgrammer.IConfig<Output>,
19
+ "decoder" | "path" | "trace"
20
+ >,
21
+ ) =>
22
+ (importer: FunctionImporter) =>
23
+ (obj: MetadataObject) =>
24
+ (input: ts.Expression) =>
25
+ obj.properties.map((prop) => {
26
+ const sole: string | null = prop.key.getSoleLiteral();
27
+ const propInput =
28
+ sole === null
29
+ ? ts.factory.createIdentifier("value")
30
+ : Escaper.variable(sole)
31
+ ? ts.factory.createPropertyAccessExpression(
32
+ input,
33
+ ts.factory.createIdentifier(sole),
34
+ )
35
+ : ts.factory.createElementAccessExpression(
36
+ input,
37
+ ts.factory.createStringLiteral(sole),
38
+ );
39
+
40
+ return {
41
+ input: propInput,
42
+ key: prop.key,
43
+ meta: prop.value,
44
+ expression: config.decoder(
45
+ propInput,
46
+ prop.value,
47
+ {
48
+ tracable: config.path || config.trace,
49
+ source: "object",
50
+ from: "object",
51
+ postfix:
52
+ sole !== null
53
+ ? IdentifierFactory.postfix(sole)
54
+ : (() => {
55
+ importer.use("join");
56
+ return `$join(key)`;
57
+ })(),
58
+ },
59
+ prop.tags,
60
+ prop.jsDocTags,
61
+ ),
62
+ };
63
+ });
@@ -1,23 +1,23 @@
1
- import { MetadataTagFactory } from "../../factories/MetadataTagFactory";
2
-
3
- import { IJsDocTagInfo } from "../../metadata/IJsDocTagInfo";
4
-
5
- /**
6
- * @internal
7
- */
8
- export const get_comment_tags =
9
- (excludeMetaTags: boolean) => (jsDocTags: IJsDocTagInfo[]) =>
10
- jsDocTags
11
- .filter(
12
- (tag) =>
13
- tag.name !== "random" &&
14
- (!tag.text?.length ||
15
- (tag.text?.length === 1 &&
16
- tag.text?.[0]?.kind === "text")) &&
17
- (!excludeMetaTags ||
18
- MetadataTagFactory._PARSER[tag.name] === undefined),
19
- )
20
- .map((tag) => ({
21
- name: tag.name,
22
- value: tag.text?.[0]?.text,
23
- }));
1
+ import { MetadataTagFactory } from "../../factories/MetadataTagFactory";
2
+
3
+ import { IJsDocTagInfo } from "../../metadata/IJsDocTagInfo";
4
+
5
+ /**
6
+ * @internal
7
+ */
8
+ export const get_comment_tags =
9
+ (excludeMetaTags: boolean) => (jsDocTags: IJsDocTagInfo[]) =>
10
+ jsDocTags
11
+ .filter(
12
+ (tag) =>
13
+ tag.name !== "random" &&
14
+ (!tag.text?.length ||
15
+ (tag.text?.length === 1 &&
16
+ tag.text?.[0]?.kind === "text")) &&
17
+ (!excludeMetaTags ||
18
+ MetadataTagFactory._PARSER[tag.name] === undefined),
19
+ )
20
+ .map((tag) => ({
21
+ name: tag.name,
22
+ value: tag.text?.[0]?.text,
23
+ }));
@@ -1,34 +1,34 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
-
3
- import { ArrayUtil } from "../../utils/ArrayUtil";
4
- import { PatternUtil } from "../../utils/PatternUtil";
5
-
6
- import { template_to_pattern } from "./template_to_pattern";
7
-
8
- /**
9
- * @internal
10
- */
11
- export const metadata_to_pattern =
12
- (top: boolean) =>
13
- (meta: Metadata): string => {
14
- if (meta.atomics.find((type) => type === "string") !== undefined)
15
- return "(.*)";
16
-
17
- const values: string[] = ArrayUtil.flat(
18
- meta.constants.map((c) => {
19
- if (c.type !== "string")
20
- return c.values.map((v) => v.toString());
21
- return c.values.map((str) => PatternUtil.escape(str));
22
- }),
23
- );
24
- for (const type of meta.atomics)
25
- if (type === "number" || type === "bigint")
26
- values.push(PatternUtil.NUMBER);
27
- else if (type === "boolean") values.push(PatternUtil.BOOLEAN);
28
- for (const childTpl of meta.templates)
29
- values.push("(" + template_to_pattern(false)(childTpl) + ")");
30
-
31
- const pattern: string =
32
- values.length === 1 ? values[0]! : "(" + values.join("|") + ")";
33
- return top ? PatternUtil.fix(pattern) : pattern;
34
- };
1
+ import { Metadata } from "../../metadata/Metadata";
2
+
3
+ import { ArrayUtil } from "../../utils/ArrayUtil";
4
+ import { PatternUtil } from "../../utils/PatternUtil";
5
+
6
+ import { template_to_pattern } from "./template_to_pattern";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const metadata_to_pattern =
12
+ (top: boolean) =>
13
+ (meta: Metadata): string => {
14
+ if (meta.atomics.find((type) => type === "string") !== undefined)
15
+ return "(.*)";
16
+
17
+ const values: string[] = ArrayUtil.flat(
18
+ meta.constants.map((c) => {
19
+ if (c.type !== "string")
20
+ return c.values.map((v) => v.toString());
21
+ return c.values.map((str) => PatternUtil.escape(str));
22
+ }),
23
+ );
24
+ for (const type of meta.atomics)
25
+ if (type === "number" || type === "bigint")
26
+ values.push(PatternUtil.NUMBER);
27
+ else if (type === "boolean") values.push(PatternUtil.BOOLEAN);
28
+ for (const childTpl of meta.templates)
29
+ values.push("(" + template_to_pattern(false)(childTpl) + ")");
30
+
31
+ const pattern: string =
32
+ values.length === 1 ? values[0]! : "(" + values.join("|") + ")";
33
+ return top ? PatternUtil.fix(pattern) : pattern;
34
+ };
@@ -1,30 +1,30 @@
1
- import ts from "typescript";
2
-
3
- import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
- import { LiteralFactory } from "../../factories/LiteralFactory";
5
-
6
- import { ICommentTag } from "../../metadata/ICommentTag";
7
-
8
- import { Customizable } from "../../typings/Customizable";
9
-
10
- /**
11
- * @internal
12
- */
13
- export const random_custom =
14
- (accessor: (name: string) => ts.Expression) =>
15
- (type: keyof Customizable) =>
16
- (comments: ICommentTag[]) =>
17
- (expression: ts.Expression) =>
18
- ExpressionFactory.coalesce(
19
- ts.factory.createCallChain(
20
- ts.factory.createPropertyAccessChain(
21
- accessor("customs"),
22
- ts.factory.createToken(ts.SyntaxKind.QuestionDotToken),
23
- ts.factory.createIdentifier(type),
24
- ),
25
- ts.factory.createToken(ts.SyntaxKind.QuestionDotToken),
26
- undefined,
27
- [LiteralFactory.generate(comments)],
28
- ),
29
- expression,
30
- );
1
+ import ts from "typescript";
2
+
3
+ import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
+ import { LiteralFactory } from "../../factories/LiteralFactory";
5
+
6
+ import { ICommentTag } from "../../metadata/ICommentTag";
7
+
8
+ import { Customizable } from "../../typings/Customizable";
9
+
10
+ /**
11
+ * @internal
12
+ */
13
+ export const random_custom =
14
+ (accessor: (name: string) => ts.Expression) =>
15
+ (type: keyof Customizable) =>
16
+ (comments: ICommentTag[]) =>
17
+ (expression: ts.Expression) =>
18
+ ExpressionFactory.coalesce(
19
+ ts.factory.createCallChain(
20
+ ts.factory.createPropertyAccessChain(
21
+ accessor("customs"),
22
+ ts.factory.createToken(ts.SyntaxKind.QuestionDotToken),
23
+ ts.factory.createIdentifier(type),
24
+ ),
25
+ ts.factory.createToken(ts.SyntaxKind.QuestionDotToken),
26
+ undefined,
27
+ [LiteralFactory.generate(comments)],
28
+ ),
29
+ expression,
30
+ );
@@ -1,168 +1,168 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
- import { TemplateFactory } from "../../factories/TemplateFactory";
5
-
6
- import { IExpressionEntry } from "../helpers/IExpressionEntry";
7
- import { metadata_to_pattern } from "./metadata_to_pattern";
8
-
9
- /**
10
- * @internal
11
- */
12
- export function stringify_dynamic_properties(
13
- dynamic: IExpressionEntry<ts.Expression>[],
14
- regular: string[],
15
- ): ts.Expression {
16
- // BASIC STATMEMENT, CHECK UNDEFINED
17
- const statements: ts.Statement[] = [
18
- ts.factory.createIfStatement(
19
- ts.factory.createStrictEquality(
20
- ts.factory.createIdentifier("undefined"),
21
- ts.factory.createIdentifier("value"),
22
- ),
23
- ts.factory.createReturnStatement(
24
- ts.factory.createStringLiteral(""),
25
- ),
26
- ),
27
- ];
28
-
29
- // PREPARE RETURN FUNCTION
30
- const output = () => {
31
- const mapped = ts.factory.createCallExpression(
32
- IdentifierFactory.join(
33
- ts.factory.createCallExpression(
34
- ts.factory.createIdentifier("Object.entries"),
35
- undefined,
36
- [ts.factory.createIdentifier("input")],
37
- ),
38
- "map",
39
- ),
40
- undefined,
41
- [
42
- ts.factory.createArrowFunction(
43
- undefined,
44
- undefined,
45
- [
46
- IdentifierFactory.parameter(
47
- ts.factory.createArrayBindingPattern([
48
- ts.factory.createBindingElement(
49
- undefined,
50
- undefined,
51
- "key",
52
- ),
53
- ts.factory.createBindingElement(
54
- undefined,
55
- undefined,
56
- "value",
57
- ),
58
- ]),
59
- ts.factory.createTypeReferenceNode("[string, any]"),
60
- ),
61
- ],
62
- undefined,
63
- undefined,
64
- ts.factory.createBlock(statements),
65
- ),
66
- ],
67
- );
68
- const filtered = ts.factory.createCallExpression(
69
- IdentifierFactory.join(mapped, "filter"),
70
- undefined,
71
- [
72
- ts.factory.createArrowFunction(
73
- undefined,
74
- undefined,
75
- [IdentifierFactory.parameter("str")],
76
- undefined,
77
- undefined,
78
- ts.factory.createStrictInequality(
79
- ts.factory.createStringLiteral(""),
80
- ts.factory.createIdentifier("str"),
81
- ),
82
- ),
83
- ],
84
- );
85
- return ts.factory.createCallExpression(
86
- IdentifierFactory.join(filtered, "join"),
87
- undefined,
88
- [ts.factory.createStringLiteral(",")],
89
- );
90
- };
91
-
92
- // WHEN REGULAR PROPERTY EXISTS
93
- if (regular.length)
94
- statements.push(
95
- ts.factory.createIfStatement(
96
- ts.factory.createCallExpression(
97
- IdentifierFactory.join(
98
- ts.factory.createArrayLiteralExpression(
99
- regular.map((key) =>
100
- ts.factory.createStringLiteral(key),
101
- ),
102
- ),
103
- "some",
104
- ),
105
- undefined,
106
- [
107
- ts.factory.createArrowFunction(
108
- undefined,
109
- undefined,
110
- [IdentifierFactory.parameter("regular")],
111
- undefined,
112
- undefined,
113
- ts.factory.createStrictEquality(
114
- ts.factory.createIdentifier("regular"),
115
- ts.factory.createIdentifier("key"),
116
- ),
117
- ),
118
- ],
119
- ),
120
- ts.factory.createReturnStatement(
121
- ts.factory.createStringLiteral(""),
122
- ),
123
- ),
124
- );
125
-
126
- // ONLY STRING TYPED KEY EXISTS
127
- const simple: boolean =
128
- dynamic.length === 1 &&
129
- dynamic[0]!.key.size() === 1 &&
130
- dynamic[0]!.key.atomics[0] === "string";
131
- if (simple === true) {
132
- statements.push(stringify(dynamic[0]!));
133
- return output();
134
- }
135
-
136
- // COMPOSITE TEMPLATE LITERAL TYPES
137
- for (const entry of dynamic) {
138
- const condition: ts.IfStatement = ts.factory.createIfStatement(
139
- ts.factory.createCallExpression(
140
- ts.factory.createIdentifier(
141
- `RegExp(/${metadata_to_pattern(true)(entry.key)}/).test`,
142
- ),
143
- undefined,
144
- [ts.factory.createIdentifier("key")],
145
- ),
146
- stringify(entry),
147
- );
148
- statements.push(condition);
149
- }
150
- return output();
151
- }
152
-
153
- /**
154
- * @internal
155
- */
156
- function stringify(entry: IExpressionEntry<ts.Expression>): ts.ReturnStatement {
157
- return ts.factory.createReturnStatement(
158
- TemplateFactory.generate([
159
- ts.factory.createCallExpression(
160
- ts.factory.createIdentifier("JSON.stringify"),
161
- [],
162
- [ts.factory.createIdentifier("key")],
163
- ),
164
- ts.factory.createStringLiteral(":"),
165
- entry.expression,
166
- ]),
167
- );
168
- }
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+ import { TemplateFactory } from "../../factories/TemplateFactory";
5
+
6
+ import { IExpressionEntry } from "../helpers/IExpressionEntry";
7
+ import { metadata_to_pattern } from "./metadata_to_pattern";
8
+
9
+ /**
10
+ * @internal
11
+ */
12
+ export function stringify_dynamic_properties(
13
+ dynamic: IExpressionEntry<ts.Expression>[],
14
+ regular: string[],
15
+ ): ts.Expression {
16
+ // BASIC STATMEMENT, CHECK UNDEFINED
17
+ const statements: ts.Statement[] = [
18
+ ts.factory.createIfStatement(
19
+ ts.factory.createStrictEquality(
20
+ ts.factory.createIdentifier("undefined"),
21
+ ts.factory.createIdentifier("value"),
22
+ ),
23
+ ts.factory.createReturnStatement(
24
+ ts.factory.createStringLiteral(""),
25
+ ),
26
+ ),
27
+ ];
28
+
29
+ // PREPARE RETURN FUNCTION
30
+ const output = () => {
31
+ const mapped = ts.factory.createCallExpression(
32
+ IdentifierFactory.join(
33
+ ts.factory.createCallExpression(
34
+ ts.factory.createIdentifier("Object.entries"),
35
+ undefined,
36
+ [ts.factory.createIdentifier("input")],
37
+ ),
38
+ "map",
39
+ ),
40
+ undefined,
41
+ [
42
+ ts.factory.createArrowFunction(
43
+ undefined,
44
+ undefined,
45
+ [
46
+ IdentifierFactory.parameter(
47
+ ts.factory.createArrayBindingPattern([
48
+ ts.factory.createBindingElement(
49
+ undefined,
50
+ undefined,
51
+ "key",
52
+ ),
53
+ ts.factory.createBindingElement(
54
+ undefined,
55
+ undefined,
56
+ "value",
57
+ ),
58
+ ]),
59
+ ts.factory.createTypeReferenceNode("[string, any]"),
60
+ ),
61
+ ],
62
+ undefined,
63
+ undefined,
64
+ ts.factory.createBlock(statements),
65
+ ),
66
+ ],
67
+ );
68
+ const filtered = ts.factory.createCallExpression(
69
+ IdentifierFactory.join(mapped, "filter"),
70
+ undefined,
71
+ [
72
+ ts.factory.createArrowFunction(
73
+ undefined,
74
+ undefined,
75
+ [IdentifierFactory.parameter("str")],
76
+ undefined,
77
+ undefined,
78
+ ts.factory.createStrictInequality(
79
+ ts.factory.createStringLiteral(""),
80
+ ts.factory.createIdentifier("str"),
81
+ ),
82
+ ),
83
+ ],
84
+ );
85
+ return ts.factory.createCallExpression(
86
+ IdentifierFactory.join(filtered, "join"),
87
+ undefined,
88
+ [ts.factory.createStringLiteral(",")],
89
+ );
90
+ };
91
+
92
+ // WHEN REGULAR PROPERTY EXISTS
93
+ if (regular.length)
94
+ statements.push(
95
+ ts.factory.createIfStatement(
96
+ ts.factory.createCallExpression(
97
+ IdentifierFactory.join(
98
+ ts.factory.createArrayLiteralExpression(
99
+ regular.map((key) =>
100
+ ts.factory.createStringLiteral(key),
101
+ ),
102
+ ),
103
+ "some",
104
+ ),
105
+ undefined,
106
+ [
107
+ ts.factory.createArrowFunction(
108
+ undefined,
109
+ undefined,
110
+ [IdentifierFactory.parameter("regular")],
111
+ undefined,
112
+ undefined,
113
+ ts.factory.createStrictEquality(
114
+ ts.factory.createIdentifier("regular"),
115
+ ts.factory.createIdentifier("key"),
116
+ ),
117
+ ),
118
+ ],
119
+ ),
120
+ ts.factory.createReturnStatement(
121
+ ts.factory.createStringLiteral(""),
122
+ ),
123
+ ),
124
+ );
125
+
126
+ // ONLY STRING TYPED KEY EXISTS
127
+ const simple: boolean =
128
+ dynamic.length === 1 &&
129
+ dynamic[0]!.key.size() === 1 &&
130
+ dynamic[0]!.key.atomics[0] === "string";
131
+ if (simple === true) {
132
+ statements.push(stringify(dynamic[0]!));
133
+ return output();
134
+ }
135
+
136
+ // COMPOSITE TEMPLATE LITERAL TYPES
137
+ for (const entry of dynamic) {
138
+ const condition: ts.IfStatement = ts.factory.createIfStatement(
139
+ ts.factory.createCallExpression(
140
+ ts.factory.createIdentifier(
141
+ `RegExp(/${metadata_to_pattern(true)(entry.key)}/).test`,
142
+ ),
143
+ undefined,
144
+ [ts.factory.createIdentifier("key")],
145
+ ),
146
+ stringify(entry),
147
+ );
148
+ statements.push(condition);
149
+ }
150
+ return output();
151
+ }
152
+
153
+ /**
154
+ * @internal
155
+ */
156
+ function stringify(entry: IExpressionEntry<ts.Expression>): ts.ReturnStatement {
157
+ return ts.factory.createReturnStatement(
158
+ TemplateFactory.generate([
159
+ ts.factory.createCallExpression(
160
+ ts.factory.createIdentifier("JSON.stringify"),
161
+ [],
162
+ [ts.factory.createIdentifier("key")],
163
+ ),
164
+ ts.factory.createStringLiteral(":"),
165
+ entry.expression,
166
+ ]),
167
+ );
168
+ }