@@ -103,7 +103,7 @@ func (c *Checker) checkJsxFragment(node *ast.Node) *Type {
103
103
// by default, jsx:'react' will use jsxFactory = React.createElement and jsxFragmentFactory = React.Fragment
104
104
// if jsxFactory compiler option is provided, ensure jsxFragmentFactory compiler option or @jsxFrag pragma is provided too
105
105
nodeSourceFile := ast .GetSourceFileOfNode (node )
106
- if c .compilerOptions .GetJSXTransformEnabled () && (c .compilerOptions .JsxFactory != "" || getPragmaFromSourceFile (nodeSourceFile , "jsx" ) != nil ) && c .compilerOptions .JsxFragmentFactory == "" && getPragmaFromSourceFile (nodeSourceFile , "jsxfrag" ) == nil {
106
+ if c .compilerOptions .GetJSXTransformEnabled () && (c .compilerOptions .JsxFactory != "" || ast . GetPragmaFromSourceFile (nodeSourceFile , "jsx" ) != nil ) && c .compilerOptions .JsxFragmentFactory == "" && ast . GetPragmaFromSourceFile (nodeSourceFile , "jsxfrag" ) == nil {
107
107
message := core .IfElse (c .compilerOptions .JsxFactory != "" ,
108
108
diagnostics .The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option ,
109
109
diagnostics .An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments )
@@ -377,10 +377,10 @@ func (c *Checker) resolveJsxOpeningLikeElement(node *ast.Node, candidatesOutArra
377
377
result := c .getIntrinsicAttributesTypeFromJsxOpeningLikeElement (node )
378
378
fakeSignature := c .createSignatureForJSXIntrinsic (node , result )
379
379
c .checkTypeAssignableToAndOptionallyElaborate (c .checkExpressionWithContextualType (node .Attributes (), c .getEffectiveFirstArgumentForJsxSignature (fakeSignature , node ), nil /*inferenceContext*/ , CheckModeNormal ), result , node .TagName (), node .Attributes (), nil , nil )
380
- typeArgumentList := node .TypeArgumentList ()
381
- if typeArgumentList != nil {
382
- c .checkSourceElements (typeArgumentList . Nodes )
383
- c .diagnostics .Add (ast .NewDiagnostic (ast .GetSourceFileOfNode (node ), node .TypeArgumentList ().Loc , diagnostics .Expected_0_type_arguments_but_got_1 , 0 , len (typeArgumentList . Nodes )))
380
+ typeArguments := node .TypeArguments ()
381
+ if len ( typeArguments ) != 0 {
382
+ c .checkSourceElements (typeArguments )
383
+ c .diagnostics .Add (ast .NewDiagnostic (ast .GetSourceFileOfNode (node ), node .TypeArgumentList ().Loc , diagnostics .Expected_0_type_arguments_but_got_1 , 0 , len (typeArguments )))
384
384
}
385
385
return fakeSignature
386
386
}
@@ -1134,7 +1134,7 @@ func (c *Checker) getJsxNamespace(location *ast.Node) string {
1134
1134
if links .localJsxFragmentNamespace != "" {
1135
1135
return links .localJsxFragmentNamespace
1136
1136
}
1137
- jsxFragmentPragma := getPragmaFromSourceFile (file , "jsxfrag" )
1137
+ jsxFragmentPragma := ast . GetPragmaFromSourceFile (file , "jsxfrag" )
1138
1138
if jsxFragmentPragma != nil {
1139
1139
links .localJsxFragmentFactory = c .parseIsolatedEntityName (jsxFragmentPragma .Args ["factory" ].Value )
1140
1140
if links .localJsxFragmentFactory != nil {
@@ -1179,7 +1179,7 @@ func (c *Checker) getLocalJsxNamespace(file *ast.SourceFile) string {
1179
1179
if links .localJsxNamespace != "" {
1180
1180
return links .localJsxNamespace
1181
1181
}
1182
- jsxPragma := getPragmaFromSourceFile (file , "jsx" )
1182
+ jsxPragma := ast . GetPragmaFromSourceFile (file , "jsx" )
1183
1183
if jsxPragma != nil {
1184
1184
links .localJsxFactory = c .parseIsolatedEntityName (jsxPragma .Args ["factory" ].Value )
1185
1185
if links .localJsxFactory != nil {
@@ -1208,7 +1208,7 @@ func (c *Checker) getJsxFragmentFactoryEntity(location *ast.Node) *ast.EntityNam
1208
1208
if links .localJsxFragmentFactory != nil {
1209
1209
return links .localJsxFragmentFactory
1210
1210
}
1211
- jsxFragPragma := getPragmaFromSourceFile (file , "jsxfrag" )
1211
+ jsxFragPragma := ast . GetPragmaFromSourceFile (file , "jsxfrag" )
1212
1212
if jsxFragPragma != nil {
1213
1213
links .localJsxFragmentFactory = c .parseIsolatedEntityName (jsxFragPragma .Args ["factory" ].Value )
1214
1214
return links .localJsxFragmentFactory
@@ -1246,7 +1246,6 @@ func (c *Checker) getJsxNamespaceContainerForImplicitImport(location *ast.Node)
1246
1246
if links != nil && links .jsxImplicitImportContainer != nil {
1247
1247
return core .IfElse (links .jsxImplicitImportContainer == c .unknownSymbol , nil , links .jsxImplicitImportContainer )
1248
1248
}
1249
-
1250
1249
moduleReference , specifier := c .getJSXRuntimeImportSpecifier (file )
1251
1250
if moduleReference == "" {
1252
1251
return nil
@@ -1266,23 +1265,3 @@ func (c *Checker) getJsxNamespaceContainerForImplicitImport(location *ast.Node)
1266
1265
func (c * Checker ) getJSXRuntimeImportSpecifier (file * ast.SourceFile ) (moduleReference string , specifier * ast.Node ) {
1267
1266
return c .program .GetJSXRuntimeImportSpecifier (file .Path ())
1268
1267
}
1269
-
1270
- func getPragmaFromSourceFile (file * ast.SourceFile , name string ) * ast.Pragma {
1271
- if file != nil {
1272
- for i := range file .Pragmas {
1273
- if file .Pragmas [i ].Name == name {
1274
- return & file .Pragmas [i ]
1275
- }
1276
- }
1277
- }
1278
- return nil
1279
- }
1280
-
1281
- func getPragmaArgument (pragma * ast.Pragma , name string ) string {
1282
- if pragma != nil {
1283
- if arg , ok := pragma .Args [name ]; ok {
1284
- return arg .Value
1285
- }
1286
- }
1287
- return ""
1288
- }
0 commit comments