typia 3.5.0-dev.20230212 → 3.5.0-dev.20230213

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.
@@ -0,0 +1,31 @@
1
+ import ts from "typescript";
2
+
3
+ import { CloneProgrammer } from "../../../programmers/CloneProgrammer";
4
+
5
+ import { IProject } from "../../IProject";
6
+
7
+ export namespace CreateCloneTransformer {
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
+ return CloneProgrammer.generate(project, modulo)(type);
25
+ }
26
+ }
27
+
28
+ const enum ErrorMessages {
29
+ NOT_SPECIFIED = "Error on typia.clone(): generic argument is not specified.",
30
+ GENERIC_ARGUMENT = "Error on typia.clone(): non-specified generic argument.",
31
+ }