typia 13.0.0-dev.20260510 → 13.0.0-dev.20260514

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.
@@ -1,229 +1,229 @@
1
1
  package printer
2
2
 
3
3
  import (
4
- shimast "github.com/microsoft/typescript-go/shim/ast"
5
- shimprinter "github.com/microsoft/typescript-go/shim/printer"
4
+ shimast "github.com/microsoft/typescript-go/shim/ast"
5
+ shimprinter "github.com/microsoft/typescript-go/shim/printer"
6
6
  )
7
7
 
8
8
  const kindColonToken = shimast.KindQuestionToken + 1
9
9
 
10
10
  func EmitWithIdentifierSubstitutions(node *shimast.Node, sourceFile *shimast.SourceFile, substitutions map[string]string) string {
11
- node = stripTypeSyntax(node)
12
- node = rewriteIdentifiers(node, substitutions)
13
- normalizeSyntheticTokens(node)
14
- return emit(node, sourceFile)
11
+ node = stripTypeSyntax(node)
12
+ node = rewriteIdentifiers(node, substitutions)
13
+ normalizeSyntheticTokens(node)
14
+ return emit(node, sourceFile)
15
15
  }
16
16
 
17
17
  func EmitPreservingTypesWithIdentifierSubstitutions(node *shimast.Node, sourceFile *shimast.SourceFile, substitutions map[string]string) string {
18
- node = rewriteIdentifiers(node, substitutions)
19
- normalizeSyntheticTokens(node)
20
- return emit(node, sourceFile)
18
+ node = rewriteIdentifiers(node, substitutions)
19
+ normalizeSyntheticTokens(node)
20
+ return emit(node, sourceFile)
21
21
  }
22
22
 
23
23
  func emit(node *shimast.Node, sourceFile *shimast.SourceFile) string {
24
- return shimprinter.NewPrinter(shimprinter.PrinterOptions{
25
- RemoveComments: true,
26
- NewLine: 2,
27
- }, shimprinter.PrintHandlers{}, nil).Emit(node, sourceFile)
24
+ return shimprinter.NewPrinter(shimprinter.PrinterOptions{
25
+ RemoveComments: true,
26
+ NewLine: 2,
27
+ }, shimprinter.PrintHandlers{}, nil).Emit(node, sourceFile)
28
28
  }
29
29
 
30
30
  func stripTypeSyntax(node *shimast.Node) *shimast.Node {
31
- if node == nil {
32
- return nil
33
- }
34
- factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
35
- var visitor *shimast.NodeVisitor
36
- visitor = shimast.NewNodeVisitor(func(current *shimast.Node) *shimast.Node {
37
- if current == nil {
38
- return nil
39
- }
40
- switch current.Kind {
41
- case shimast.KindAsExpression, shimast.KindSatisfiesExpression, shimast.KindTypeAssertionExpression, shimast.KindNonNullExpression:
42
- return visitor.VisitNode(current.Expression())
43
- case shimast.KindVariableDeclaration:
44
- decl := current.AsVariableDeclaration()
45
- return factory.UpdateVariableDeclaration(
46
- decl,
47
- visitor.VisitNode(decl.Name()),
48
- nil,
49
- nil,
50
- visitor.VisitNode(decl.Initializer),
51
- )
52
- case shimast.KindParameter:
53
- parameter := current.AsParameterDeclaration()
54
- return factory.UpdateParameterDeclaration(
55
- parameter,
56
- visitor.VisitModifiers(parameter.Modifiers()),
57
- visitor.VisitNode(parameter.DotDotDotToken),
58
- visitor.VisitNode(parameter.Name()),
59
- nil,
60
- nil,
61
- visitor.VisitNode(parameter.Initializer),
62
- )
63
- case shimast.KindArrowFunction:
64
- arrow := current.AsArrowFunction()
65
- return factory.UpdateArrowFunction(
66
- arrow,
67
- visitor.VisitModifiers(arrow.Modifiers()),
68
- nil,
69
- visitor.VisitNodes(arrow.Parameters),
70
- nil,
71
- nil,
72
- visitor.VisitNode(arrow.EqualsGreaterThanToken),
73
- visitor.VisitNode(arrow.Body),
74
- )
75
- case shimast.KindCallExpression:
76
- call := current.AsCallExpression()
77
- return factory.UpdateCallExpression(
78
- call,
79
- visitor.VisitNode(call.Expression),
80
- visitor.VisitNode(call.QuestionDotToken),
81
- nil,
82
- visitor.VisitNodes(call.Arguments),
83
- call.Flags,
84
- )
85
- case shimast.KindNewExpression:
86
- expr := current.AsNewExpression()
87
- return factory.UpdateNewExpression(
88
- expr,
89
- visitor.VisitNode(expr.Expression),
90
- nil,
91
- visitor.VisitNodes(expr.Arguments),
92
- )
93
- default:
94
- return visitor.VisitEachChild(current)
95
- }
96
- }, factory, shimast.NodeVisitorHooks{})
97
- return visitor.VisitNode(node)
31
+ if node == nil {
32
+ return nil
33
+ }
34
+ factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
35
+ var visitor *shimast.NodeVisitor
36
+ visitor = shimast.NewNodeVisitor(func(current *shimast.Node) *shimast.Node {
37
+ if current == nil {
38
+ return nil
39
+ }
40
+ switch current.Kind {
41
+ case shimast.KindAsExpression, shimast.KindSatisfiesExpression, shimast.KindTypeAssertionExpression, shimast.KindNonNullExpression:
42
+ return visitor.VisitNode(current.Expression())
43
+ case shimast.KindVariableDeclaration:
44
+ decl := current.AsVariableDeclaration()
45
+ return factory.UpdateVariableDeclaration(
46
+ decl,
47
+ visitor.VisitNode(decl.Name()),
48
+ nil,
49
+ nil,
50
+ visitor.VisitNode(decl.Initializer),
51
+ )
52
+ case shimast.KindParameter:
53
+ parameter := current.AsParameterDeclaration()
54
+ return factory.UpdateParameterDeclaration(
55
+ parameter,
56
+ visitor.VisitModifiers(parameter.Modifiers()),
57
+ visitor.VisitNode(parameter.DotDotDotToken),
58
+ visitor.VisitNode(parameter.Name()),
59
+ nil,
60
+ nil,
61
+ visitor.VisitNode(parameter.Initializer),
62
+ )
63
+ case shimast.KindArrowFunction:
64
+ arrow := current.AsArrowFunction()
65
+ return factory.UpdateArrowFunction(
66
+ arrow,
67
+ visitor.VisitModifiers(arrow.Modifiers()),
68
+ nil,
69
+ visitor.VisitNodes(arrow.Parameters),
70
+ nil,
71
+ nil,
72
+ visitor.VisitNode(arrow.EqualsGreaterThanToken),
73
+ visitor.VisitNode(arrow.Body),
74
+ )
75
+ case shimast.KindCallExpression:
76
+ call := current.AsCallExpression()
77
+ return factory.UpdateCallExpression(
78
+ call,
79
+ visitor.VisitNode(call.Expression),
80
+ visitor.VisitNode(call.QuestionDotToken),
81
+ nil,
82
+ visitor.VisitNodes(call.Arguments),
83
+ call.Flags,
84
+ )
85
+ case shimast.KindNewExpression:
86
+ expr := current.AsNewExpression()
87
+ return factory.UpdateNewExpression(
88
+ expr,
89
+ visitor.VisitNode(expr.Expression),
90
+ nil,
91
+ visitor.VisitNodes(expr.Arguments),
92
+ )
93
+ default:
94
+ return visitor.VisitEachChild(current)
95
+ }
96
+ }, factory, shimast.NodeVisitorHooks{})
97
+ return visitor.VisitNode(node)
98
98
  }
99
99
 
100
100
  func rewriteIdentifiers(node *shimast.Node, substitutions map[string]string) *shimast.Node {
101
- if node == nil || len(substitutions) == 0 {
102
- return node
103
- }
104
- factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
105
- var visitor *shimast.NodeVisitor
106
- visitor = shimast.NewNodeVisitor(func(current *shimast.Node) *shimast.Node {
107
- if current == nil {
108
- return nil
109
- }
110
- switch current.Kind {
111
- case shimast.KindIdentifier:
112
- if replacement, ok := substitutions[current.Text()]; ok {
113
- return rewriteIdentifierExpression(factory, replacement)
114
- }
115
- return current
116
- case shimast.KindVariableDeclaration:
117
- decl := current.AsVariableDeclaration()
118
- return factory.UpdateVariableDeclaration(
119
- decl,
120
- decl.Name(),
121
- nil,
122
- nil,
123
- visitor.VisitNode(decl.Initializer),
124
- )
125
- case shimast.KindParameter:
126
- parameter := current.AsParameterDeclaration()
127
- return factory.UpdateParameterDeclaration(
128
- parameter,
129
- parameter.Modifiers(),
130
- parameter.DotDotDotToken,
131
- parameter.Name(),
132
- nil,
133
- nil,
134
- visitor.VisitNode(parameter.Initializer),
135
- )
136
- case shimast.KindPropertyAssignment:
137
- assignment := current.AsPropertyAssignment()
138
- return factory.UpdatePropertyAssignment(
139
- assignment,
140
- assignment.Modifiers(),
141
- assignment.Name(),
142
- assignment.PostfixToken,
143
- nil,
144
- visitor.VisitNode(assignment.Initializer),
145
- )
146
- case shimast.KindShorthandPropertyAssignment:
147
- assignment := current.AsShorthandPropertyAssignment()
148
- name := assignment.Name()
149
- if name != nil && name.Kind == shimast.KindIdentifier {
150
- if replacement, ok := substitutions[name.Text()]; ok && assignment.ObjectAssignmentInitializer == nil {
151
- return factory.NewPropertyAssignment(
152
- assignment.Modifiers(),
153
- name,
154
- assignment.PostfixToken,
155
- nil,
156
- rewriteIdentifierExpression(factory, replacement),
157
- )
158
- }
159
- }
160
- return factory.UpdateShorthandPropertyAssignment(
161
- assignment,
162
- assignment.Modifiers(),
163
- name,
164
- assignment.PostfixToken,
165
- nil,
166
- nil,
167
- visitor.VisitNode(assignment.ObjectAssignmentInitializer),
168
- )
169
- case shimast.KindPropertyAccessExpression:
170
- access := current.AsPropertyAccessExpression()
171
- return factory.UpdatePropertyAccessExpression(
172
- access,
173
- visitor.VisitNode(access.Expression),
174
- access.QuestionDotToken,
175
- access.Name(),
176
- access.Flags,
177
- )
178
- default:
179
- return visitor.VisitEachChild(current)
180
- }
181
- }, factory, shimast.NodeVisitorHooks{})
182
- return visitor.VisitNode(node)
101
+ if node == nil || len(substitutions) == 0 {
102
+ return node
103
+ }
104
+ factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
105
+ var visitor *shimast.NodeVisitor
106
+ visitor = shimast.NewNodeVisitor(func(current *shimast.Node) *shimast.Node {
107
+ if current == nil {
108
+ return nil
109
+ }
110
+ switch current.Kind {
111
+ case shimast.KindIdentifier:
112
+ if replacement, ok := substitutions[current.Text()]; ok {
113
+ return rewriteIdentifierExpression(factory, replacement)
114
+ }
115
+ return current
116
+ case shimast.KindVariableDeclaration:
117
+ decl := current.AsVariableDeclaration()
118
+ return factory.UpdateVariableDeclaration(
119
+ decl,
120
+ decl.Name(),
121
+ nil,
122
+ nil,
123
+ visitor.VisitNode(decl.Initializer),
124
+ )
125
+ case shimast.KindParameter:
126
+ parameter := current.AsParameterDeclaration()
127
+ return factory.UpdateParameterDeclaration(
128
+ parameter,
129
+ parameter.Modifiers(),
130
+ parameter.DotDotDotToken,
131
+ parameter.Name(),
132
+ nil,
133
+ nil,
134
+ visitor.VisitNode(parameter.Initializer),
135
+ )
136
+ case shimast.KindPropertyAssignment:
137
+ assignment := current.AsPropertyAssignment()
138
+ return factory.UpdatePropertyAssignment(
139
+ assignment,
140
+ assignment.Modifiers(),
141
+ assignment.Name(),
142
+ assignment.PostfixToken,
143
+ nil,
144
+ visitor.VisitNode(assignment.Initializer),
145
+ )
146
+ case shimast.KindShorthandPropertyAssignment:
147
+ assignment := current.AsShorthandPropertyAssignment()
148
+ name := assignment.Name()
149
+ if name != nil && name.Kind == shimast.KindIdentifier {
150
+ if replacement, ok := substitutions[name.Text()]; ok && assignment.ObjectAssignmentInitializer == nil {
151
+ return factory.NewPropertyAssignment(
152
+ assignment.Modifiers(),
153
+ name,
154
+ assignment.PostfixToken,
155
+ nil,
156
+ rewriteIdentifierExpression(factory, replacement),
157
+ )
158
+ }
159
+ }
160
+ return factory.UpdateShorthandPropertyAssignment(
161
+ assignment,
162
+ assignment.Modifiers(),
163
+ name,
164
+ assignment.PostfixToken,
165
+ nil,
166
+ nil,
167
+ visitor.VisitNode(assignment.ObjectAssignmentInitializer),
168
+ )
169
+ case shimast.KindPropertyAccessExpression:
170
+ access := current.AsPropertyAccessExpression()
171
+ return factory.UpdatePropertyAccessExpression(
172
+ access,
173
+ visitor.VisitNode(access.Expression),
174
+ access.QuestionDotToken,
175
+ access.Name(),
176
+ access.Flags,
177
+ )
178
+ default:
179
+ return visitor.VisitEachChild(current)
180
+ }
181
+ }, factory, shimast.NodeVisitorHooks{})
182
+ return visitor.VisitNode(node)
183
183
  }
184
184
 
185
185
  func rewriteIdentifierExpression(factory *shimast.NodeFactory, replacement string) *shimast.Node {
186
- parts := []string{}
187
- start := 0
188
- for i := 0; i <= len(replacement); i++ {
189
- if i == len(replacement) || replacement[i] == '.' {
190
- if start < i {
191
- parts = append(parts, replacement[start:i])
192
- }
193
- start = i + 1
194
- }
195
- }
196
- if len(parts) == 0 {
197
- return factory.NewIdentifier(replacement)
198
- }
199
- output := factory.NewIdentifier(parts[0])
200
- for _, part := range parts[1:] {
201
- output = factory.NewPropertyAccessExpression(
202
- output,
203
- nil,
204
- factory.NewIdentifier(part),
205
- shimast.NodeFlagsNone,
206
- )
207
- }
208
- return output
186
+ parts := []string{}
187
+ start := 0
188
+ for i := 0; i <= len(replacement); i++ {
189
+ if i == len(replacement) || replacement[i] == '.' {
190
+ if start < i {
191
+ parts = append(parts, replacement[start:i])
192
+ }
193
+ start = i + 1
194
+ }
195
+ }
196
+ if len(parts) == 0 {
197
+ return factory.NewIdentifier(replacement)
198
+ }
199
+ output := factory.NewIdentifier(parts[0])
200
+ for _, part := range parts[1:] {
201
+ output = factory.NewPropertyAccessExpression(
202
+ output,
203
+ nil,
204
+ factory.NewIdentifier(part),
205
+ shimast.NodeFlagsNone,
206
+ )
207
+ }
208
+ return output
209
209
  }
210
210
 
211
211
  func normalizeSyntheticTokens(node *shimast.Node) {
212
- if node == nil {
213
- return
214
- }
215
- if node.Kind == shimast.KindConditionalExpression {
216
- conditional := node.AsConditionalExpression()
217
- factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
218
- if conditional.QuestionToken == nil {
219
- conditional.QuestionToken = factory.NewToken(shimast.KindQuestionToken)
220
- }
221
- if conditional.ColonToken == nil {
222
- conditional.ColonToken = factory.NewToken(kindColonToken)
223
- }
224
- }
225
- node.ForEachChild(func(child *shimast.Node) bool {
226
- normalizeSyntheticTokens(child)
227
- return false
228
- })
212
+ if node == nil {
213
+ return
214
+ }
215
+ if node.Kind == shimast.KindConditionalExpression {
216
+ conditional := node.AsConditionalExpression()
217
+ factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
218
+ if conditional.QuestionToken == nil {
219
+ conditional.QuestionToken = factory.NewToken(shimast.KindQuestionToken)
220
+ }
221
+ if conditional.ColonToken == nil {
222
+ conditional.ColonToken = factory.NewToken(kindColonToken)
223
+ }
224
+ }
225
+ node.ForEachChild(func(child *shimast.Node) bool {
226
+ normalizeSyntheticTokens(child)
227
+ return false
228
+ })
229
229
  }
@@ -29,10 +29,19 @@ type CallExpressionTransformer_TransformProps struct {
29
29
  Expression *shimast.CallExpression
30
30
  }
31
31
 
32
+ type CallExpressionTransformer_TransformKnownProps struct {
33
+ Context nativecontext.ITypiaContext
34
+ Expression *shimast.CallExpression
35
+ Module string
36
+ Method string
37
+ }
38
+
32
39
  type callExpressionTransformerTask func(props ITransformProps) *shimast.Node
33
40
 
34
41
  type callExpressionTransformerFunctor func() callExpressionTransformerTask
35
42
 
43
+ var callExpressionTransformer_functors = callExpressionTransformer_createFunctors()
44
+
36
45
  func (callExpressionTransformerNamespace) Transform(props CallExpressionTransformer_TransformProps) *shimast.Node {
37
46
  if props.Expression == nil {
38
47
  return nil
@@ -59,8 +68,20 @@ func (callExpressionTransformerNamespace) Transform(props CallExpressionTransfor
59
68
  return props.Expression.AsNode()
60
69
  }
61
70
  name := typ.Symbol().Name
71
+ return CallExpressionTransformer.TransformKnown(CallExpressionTransformer_TransformKnownProps{
72
+ Context: props.Context,
73
+ Expression: props.Expression,
74
+ Module: module,
75
+ Method: name,
76
+ })
77
+ }
78
+
79
+ func (callExpressionTransformerNamespace) TransformKnown(props CallExpressionTransformer_TransformKnownProps) *shimast.Node {
80
+ if props.Expression == nil {
81
+ return nil
82
+ }
62
83
  functors := callExpressionTransformer_FUNCTORS()
63
- functor, ok := functors[module][name]
84
+ functor, ok := functors[props.Module][props.Method]
64
85
  if ok == false {
65
86
  return props.Expression.AsNode()
66
87
  }
@@ -101,6 +122,10 @@ func callExpressionTransformer_sourceFile(node *shimast.Node) *shimast.SourceFil
101
122
  }
102
123
 
103
124
  func callExpressionTransformer_FUNCTORS() map[string]map[string]callExpressionTransformerFunctor {
125
+ return callExpressionTransformer_functors
126
+ }
127
+
128
+ func callExpressionTransformer_createFunctors() map[string]map[string]callExpressionTransformerFunctor {
104
129
  return map[string]map[string]callExpressionTransformerFunctor{
105
130
  "module": {
106
131
  "assert": func() callExpressionTransformerTask {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "13.0.0-dev.20260510",
3
+ "version": "13.0.0-dev.20260514",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -44,8 +44,8 @@
44
44
  "commander": "^10.0.0",
45
45
  "inquirer": "^8.2.5",
46
46
  "randexp": "^0.5.3",
47
- "@typia/interface": "^13.0.0-dev.20260510",
48
- "@typia/utils": "^13.0.0-dev.20260510"
47
+ "@typia/interface": "^13.0.0-dev.20260514",
48
+ "@typia/utils": "^13.0.0-dev.20260514"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@rollup/plugin-commonjs": "^29.0.0",
@@ -63,7 +63,7 @@
63
63
  "rollup-plugin-node-externals": "^8.1.2",
64
64
  "suppress-warnings": "^1.0.2",
65
65
  "tinyglobby": "^0.2.12",
66
- "ttsc": "^0.10.0"
66
+ "ttsc": "^0.10.2"
67
67
  },
68
68
  "sideEffects": [
69
69
  "./lib/_virtual/*.mjs",
@@ -43,7 +43,7 @@ const main = async (): Promise<void> => {
43
43
  const type: string | undefined = process.argv[2];
44
44
  if (type === "generate") {
45
45
  loadNativePreview();
46
- const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard");
46
+ const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard.js");
47
47
  await TypiaGenerateWizard.generate();
48
48
  } else halt(USAGE);
49
49
  };