typia 3.5.0-dev.20230211 → 3.5.0-dev.20230212
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/lib/module.d.ts +178 -4
- package/lib/module.js +53 -2
- package/lib/module.js.map +1 -1
- package/lib/programmers/AssertPruneProgrammer.d.ts +5 -0
- package/lib/programmers/AssertPruneProgrammer.js +37 -0
- package/lib/programmers/AssertPruneProgrammer.js.map +1 -0
- package/lib/programmers/IsPruneProgrammer.d.ts +5 -0
- package/lib/programmers/IsPruneProgrammer.js +37 -0
- package/lib/programmers/IsPruneProgrammer.js.map +1 -0
- package/lib/programmers/PruneProgrammer.js +2 -2
- package/lib/programmers/PruneProgrammer.js.map +1 -1
- package/lib/programmers/ValidatePruneProgrammer.d.ts +5 -0
- package/lib/programmers/ValidatePruneProgrammer.js +37 -0
- package/lib/programmers/ValidatePruneProgrammer.js.map +1 -0
- package/lib/programmers/internal/feature_object_entries.d.ts +1 -1
- package/lib/transformers/CallExpressionTransformer.js +12 -0
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/AssertPruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/AssertPruneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/AssertPruneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js +17 -0
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js +17 -0
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js +17 -0
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/IsPruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/IsPruneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/IsPruneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/ValidatePruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/ValidatePruneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/ValidatePruneTransformer.js.map +1 -0
- package/package.json +1 -1
- package/src/module.ts +278 -5
- package/src/programmers/AssertPruneProgrammer.ts +59 -0
- package/src/programmers/IsPruneProgrammer.ts +63 -0
- package/src/programmers/PruneProgrammer.ts +5 -2
- package/src/programmers/ValidatePruneProgrammer.ts +73 -0
- package/src/transformers/CallExpressionTransformer.ts +12 -0
- package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +38 -0
- package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +38 -0
- package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +38 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IdentifierFactory } from "../factories/IdentifierFactory";
|
|
4
|
+
import { StatementFactory } from "../factories/StatementFactory";
|
|
5
|
+
|
|
6
|
+
import { IProject } from "../transformers/IProject";
|
|
7
|
+
|
|
8
|
+
import { IsProgrammer } from "./IsProgrammer";
|
|
9
|
+
import { PruneProgrammer } from "./PruneProgrammer";
|
|
10
|
+
|
|
11
|
+
export namespace IsPruneProgrammer {
|
|
12
|
+
export const generate =
|
|
13
|
+
(project: IProject, modulo: ts.LeftHandSideExpression) =>
|
|
14
|
+
(type: ts.Type) =>
|
|
15
|
+
ts.factory.createArrowFunction(
|
|
16
|
+
undefined,
|
|
17
|
+
undefined,
|
|
18
|
+
[IdentifierFactory.parameter("input")],
|
|
19
|
+
undefined,
|
|
20
|
+
undefined,
|
|
21
|
+
ts.factory.createBlock([
|
|
22
|
+
StatementFactory.constant(
|
|
23
|
+
"is",
|
|
24
|
+
IsProgrammer.generate(project, modulo)(type),
|
|
25
|
+
),
|
|
26
|
+
StatementFactory.constant(
|
|
27
|
+
"prune",
|
|
28
|
+
PruneProgrammer.generate(
|
|
29
|
+
{
|
|
30
|
+
...project,
|
|
31
|
+
options: {
|
|
32
|
+
...project.options,
|
|
33
|
+
functional: false,
|
|
34
|
+
numeric: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
modulo,
|
|
38
|
+
)(type),
|
|
39
|
+
),
|
|
40
|
+
ts.factory.createIfStatement(
|
|
41
|
+
ts.factory.createPrefixUnaryExpression(
|
|
42
|
+
ts.SyntaxKind.ExclamationToken,
|
|
43
|
+
ts.factory.createCallExpression(
|
|
44
|
+
ts.factory.createIdentifier("is"),
|
|
45
|
+
undefined,
|
|
46
|
+
[ts.factory.createIdentifier("input")],
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
ts.factory.createReturnStatement(
|
|
50
|
+
ts.factory.createFalse(),
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
ts.factory.createExpressionStatement(
|
|
54
|
+
ts.factory.createCallExpression(
|
|
55
|
+
ts.factory.createIdentifier("prune"),
|
|
56
|
+
undefined,
|
|
57
|
+
[ts.factory.createIdentifier("input")],
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
ts.factory.createReturnStatement(ts.factory.createTrue()),
|
|
61
|
+
]),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -145,12 +145,15 @@ export namespace PruneProgrammer {
|
|
|
145
145
|
//----
|
|
146
146
|
// STATEMENTS
|
|
147
147
|
//----
|
|
148
|
-
const
|
|
148
|
+
const converter = (
|
|
149
|
+
v: ts.Expression | ts.Block | ts.ReturnStatement,
|
|
150
|
+
) =>
|
|
149
151
|
ts.isReturnStatement(v) || ts.isBlock(v)
|
|
150
152
|
? v
|
|
151
153
|
: ts.factory.createExpressionStatement(v);
|
|
154
|
+
|
|
152
155
|
const statements: ts.Statement[] = unions.map((u) =>
|
|
153
|
-
ts.factory.createIfStatement(u.is(),
|
|
156
|
+
ts.factory.createIfStatement(u.is(), converter(u.value())),
|
|
154
157
|
);
|
|
155
158
|
return ts.factory.createBlock(statements, true);
|
|
156
159
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IdentifierFactory } from "../factories/IdentifierFactory";
|
|
4
|
+
import { StatementFactory } from "../factories/StatementFactory";
|
|
5
|
+
|
|
6
|
+
import { IProject } from "../transformers/IProject";
|
|
7
|
+
|
|
8
|
+
import { PruneProgrammer } from "./PruneProgrammer";
|
|
9
|
+
import { ValidateProgrammer } from "./ValidateProgrammer";
|
|
10
|
+
|
|
11
|
+
export namespace ValidatePruneProgrammer {
|
|
12
|
+
export const generate =
|
|
13
|
+
(project: IProject, modulo: ts.LeftHandSideExpression) =>
|
|
14
|
+
(type: ts.Type) =>
|
|
15
|
+
ts.factory.createArrowFunction(
|
|
16
|
+
undefined,
|
|
17
|
+
undefined,
|
|
18
|
+
[IdentifierFactory.parameter("input")],
|
|
19
|
+
undefined,
|
|
20
|
+
undefined,
|
|
21
|
+
ts.factory.createBlock([
|
|
22
|
+
StatementFactory.constant(
|
|
23
|
+
"validate",
|
|
24
|
+
ValidateProgrammer.generate(
|
|
25
|
+
{
|
|
26
|
+
...project,
|
|
27
|
+
options: {
|
|
28
|
+
...project.options,
|
|
29
|
+
functional: false,
|
|
30
|
+
numeric: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
modulo,
|
|
34
|
+
)(type),
|
|
35
|
+
),
|
|
36
|
+
StatementFactory.constant(
|
|
37
|
+
"prune",
|
|
38
|
+
PruneProgrammer.generate(
|
|
39
|
+
{
|
|
40
|
+
...project,
|
|
41
|
+
options: {
|
|
42
|
+
...project.options,
|
|
43
|
+
functional: false,
|
|
44
|
+
numeric: false,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
modulo,
|
|
48
|
+
)(type),
|
|
49
|
+
),
|
|
50
|
+
StatementFactory.constant(
|
|
51
|
+
"output",
|
|
52
|
+
ts.factory.createCallExpression(
|
|
53
|
+
ts.factory.createIdentifier("validate"),
|
|
54
|
+
undefined,
|
|
55
|
+
[ts.factory.createIdentifier("input")],
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
ts.factory.createIfStatement(
|
|
59
|
+
ts.factory.createIdentifier("output.success"),
|
|
60
|
+
ts.factory.createExpressionStatement(
|
|
61
|
+
ts.factory.createCallExpression(
|
|
62
|
+
ts.factory.createIdentifier("prune"),
|
|
63
|
+
undefined,
|
|
64
|
+
[ts.factory.createIdentifier("input")],
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
),
|
|
68
|
+
ts.factory.createReturnStatement(
|
|
69
|
+
ts.factory.createIdentifier("output"),
|
|
70
|
+
),
|
|
71
|
+
]),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -3,9 +3,15 @@ import ts from "typescript";
|
|
|
3
3
|
|
|
4
4
|
import { IProject } from "./IProject";
|
|
5
5
|
import { ApplicationTransformer } from "./features/miscellaneous/ApplicationTransformer";
|
|
6
|
+
import { AssertPruneTransformer } from "./features/miscellaneous/AssertPruneTransformer";
|
|
7
|
+
import { CreateAssertPruneTransformer } from "./features/miscellaneous/CreateAssertPruneTransformer";
|
|
8
|
+
import { CreateIsPruneTransformer } from "./features/miscellaneous/CreateIsPruneTransformer";
|
|
6
9
|
import { CreatePruneTransformer } from "./features/miscellaneous/CreatePruneTransformer";
|
|
10
|
+
import { CreateValidatePruneTransformer } from "./features/miscellaneous/CreateValidatePruneTransformer";
|
|
11
|
+
import { IsPruneTransformer } from "./features/miscellaneous/IsPruneTransformer";
|
|
7
12
|
import { MetadataTransformer } from "./features/miscellaneous/MetadataTransformer";
|
|
8
13
|
import { PruneTransformer } from "./features/miscellaneous/PruneTransformer";
|
|
14
|
+
import { ValidatePruneTransformer } from "./features/miscellaneous/ValidatePruneTransformer";
|
|
9
15
|
import { AssertParseTransformer } from "./features/parsers/AssertParseTransformer";
|
|
10
16
|
import { CreateAssertParseTransformer } from "./features/parsers/CreateAssertParseTransformer";
|
|
11
17
|
import { CreateIsParseTransformer } from "./features/parsers/CreateIsParseTransformer";
|
|
@@ -99,6 +105,9 @@ const FUNCTORS: Record<string, () => Task> = {
|
|
|
99
105
|
application: () => ApplicationTransformer.transform,
|
|
100
106
|
metadata: () => MetadataTransformer.transform,
|
|
101
107
|
prune: () => PruneTransformer.transform,
|
|
108
|
+
assertPrune: () => AssertPruneTransformer.transform,
|
|
109
|
+
isPrune: () => IsPruneTransformer.transform,
|
|
110
|
+
validatePrune: () => ValidatePruneTransformer.transform,
|
|
102
111
|
|
|
103
112
|
//----
|
|
104
113
|
// FACTORY FUNCTIONS
|
|
@@ -127,4 +136,7 @@ const FUNCTORS: Record<string, () => Task> = {
|
|
|
127
136
|
|
|
128
137
|
// MISC
|
|
129
138
|
createPrune: () => CreatePruneTransformer.transform,
|
|
139
|
+
createAssertPrune: () => CreateAssertPruneTransformer.transform,
|
|
140
|
+
createIsPrune: () => CreateIsPruneTransformer.transform,
|
|
141
|
+
createValidatePrune: () => CreateValidatePruneTransformer.transform,
|
|
130
142
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { AssertPruneProgrammer } from "../../../programmers/AssertPruneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace AssertPruneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (expression.arguments.length !== 1)
|
|
14
|
+
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const type: ts.Type =
|
|
18
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
19
|
+
? project.checker.getTypeFromTypeNode(
|
|
20
|
+
expression.typeArguments[0],
|
|
21
|
+
)
|
|
22
|
+
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
23
|
+
if (type.isTypeParameter())
|
|
24
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
25
|
+
|
|
26
|
+
// DO TRANSFORM
|
|
27
|
+
return ts.factory.createCallExpression(
|
|
28
|
+
AssertPruneProgrammer.generate(project, modulo)(type),
|
|
29
|
+
undefined,
|
|
30
|
+
[expression.arguments[0]!],
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const enum ErrorMessages {
|
|
36
|
+
NO_INPUT_VALUE = "Error on typia.assertPrune(): no input value.",
|
|
37
|
+
GENERIC_ARGUMENT = "Error on typia.assertPrune(): non-specified generic argument.",
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { AssertPruneProgrammer } from "../../../programmers/AssertPruneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace CreateAssertPruneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
+
if (!expression.typeArguments || !expression.typeArguments[0])
|
|
15
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
|
+
|
|
17
|
+
// GET TYPE INFO
|
|
18
|
+
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
19
|
+
expression.typeArguments[0],
|
|
20
|
+
);
|
|
21
|
+
if (type.isTypeParameter())
|
|
22
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
23
|
+
|
|
24
|
+
// DO TRANSFORM
|
|
25
|
+
return AssertPruneProgrammer.generate(project, modulo)(type);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enum ErrorMessages {
|
|
30
|
+
NOT_SPECIFIED = "Error on typia.assertPrune(): generic argument is not specified.",
|
|
31
|
+
GENERIC_ARGUMENT = "Error on typia.assertPrune(): non-specified generic argument.",
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IsPruneProgrammer } from "../../../programmers/IsPruneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace CreateIsPruneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
+
if (!expression.typeArguments || !expression.typeArguments[0])
|
|
15
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
|
+
|
|
17
|
+
// GET TYPE INFO
|
|
18
|
+
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
19
|
+
expression.typeArguments[0],
|
|
20
|
+
);
|
|
21
|
+
if (type.isTypeParameter())
|
|
22
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
23
|
+
|
|
24
|
+
// DO TRANSFORM
|
|
25
|
+
return IsPruneProgrammer.generate(project, modulo)(type);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enum ErrorMessages {
|
|
30
|
+
NOT_SPECIFIED = "Error on typia.isPrune(): generic argument is not specified.",
|
|
31
|
+
GENERIC_ARGUMENT = "Error on typia.isPrune(): non-specified generic argument.",
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ValidatePruneProgrammer } from "../../../programmers/ValidatePruneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace CreateValidatePruneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
+
if (!expression.typeArguments || !expression.typeArguments[0])
|
|
15
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
|
+
|
|
17
|
+
// GET TYPE INFO
|
|
18
|
+
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
19
|
+
expression.typeArguments[0],
|
|
20
|
+
);
|
|
21
|
+
if (type.isTypeParameter())
|
|
22
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
23
|
+
|
|
24
|
+
// DO TRANSFORM
|
|
25
|
+
return ValidatePruneProgrammer.generate(project, modulo)(type);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enum ErrorMessages {
|
|
30
|
+
NOT_SPECIFIED = "Error on typia.validatePrune(): generic argument is not specified.",
|
|
31
|
+
GENERIC_ARGUMENT = "Error on typia.validatePrune(): non-specified generic argument.",
|
|
32
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IsPruneProgrammer } from "../../../programmers/IsPruneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace IsPruneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (expression.arguments.length !== 1)
|
|
14
|
+
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const type: ts.Type =
|
|
18
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
19
|
+
? project.checker.getTypeFromTypeNode(
|
|
20
|
+
expression.typeArguments[0],
|
|
21
|
+
)
|
|
22
|
+
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
23
|
+
if (type.isTypeParameter())
|
|
24
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
25
|
+
|
|
26
|
+
// DO TRANSFORM
|
|
27
|
+
return ts.factory.createCallExpression(
|
|
28
|
+
IsPruneProgrammer.generate(project, modulo)(type),
|
|
29
|
+
undefined,
|
|
30
|
+
[expression.arguments[0]!],
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const enum ErrorMessages {
|
|
36
|
+
NO_INPUT_VALUE = "Error on typia.isPrune(): no input value.",
|
|
37
|
+
GENERIC_ARGUMENT = "Error on typia.isPrune(): non-specified generic argument.",
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ValidatePruneProgrammer } from "../../../programmers/ValidatePruneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace ValidatePruneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (expression.arguments.length !== 1)
|
|
14
|
+
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const type: ts.Type =
|
|
18
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
19
|
+
? project.checker.getTypeFromTypeNode(
|
|
20
|
+
expression.typeArguments[0],
|
|
21
|
+
)
|
|
22
|
+
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
23
|
+
if (type.isTypeParameter())
|
|
24
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
25
|
+
|
|
26
|
+
// DO TRANSFORM
|
|
27
|
+
return ts.factory.createCallExpression(
|
|
28
|
+
ValidatePruneProgrammer.generate(project, modulo)(type),
|
|
29
|
+
undefined,
|
|
30
|
+
[expression.arguments[0]!],
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const enum ErrorMessages {
|
|
36
|
+
NO_INPUT_VALUE = "Error on typia.validatePrune(): no input value.",
|
|
37
|
+
GENERIC_ARGUMENT = "Error on typia.validatePrune(): non-specified generic argument.",
|
|
38
|
+
}
|