Skip to content

Commit e00c12f

Browse files
Port implicit any type arguments in JavaScript (#1242)
1 parent fa5d50b commit e00c12f

File tree

79 files changed

+1174
-1262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1174
-1262
lines changed

internal/ast/ast.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9628,6 +9628,10 @@ func (node *JSDocAugmentsTag) Clone(f NodeFactoryCoercible) *Node {
96289628
return cloneNode(f.AsNodeFactory().NewJSDocAugmentsTag(node.TagName, node.ClassName, node.Comment), node.AsNode(), f.AsNodeFactory().hooks)
96299629
}
96309630

9631+
func IsJSDocAugmentsTag(node *Node) bool {
9632+
return node.Kind == KindJSDocAugmentsTag
9633+
}
9634+
96319635
// JSDocSatisfiesTag
96329636
type JSDocSatisfiesTag struct {
96339637
JSDocTagBase

internal/checker/checker.go

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7466,12 +7466,14 @@ func (c *Checker) checkSuperExpression(node *ast.Node) *Type {
74667466
isCallExpression := ast.IsCallExpression(node.Parent) && node.Parent.Expression() == node
74677467
immediateContainer := getSuperContainer(node, true /*stopOnFunctions*/)
74687468
container := immediateContainer
7469+
74697470
// adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
74707471
if !isCallExpression {
74717472
for container != nil && ast.IsArrowFunction(container) {
74727473
container = getSuperContainer(container, true /*stopOnFunctions*/)
74737474
}
74747475
}
7476+
74757477
isLegalUsageOfSuperExpression := func() bool {
74767478
if isCallExpression {
74777479
// TS 1.0 SPEC (April 2014): 4.8.1
@@ -7492,6 +7494,7 @@ func (c *Checker) checkSuperExpression(node *ast.Node) *Type {
74927494
}
74937495
return false
74947496
}
7497+
74957498
if container == nil || !isLegalUsageOfSuperExpression() {
74967499
// issue more specific error if super is used in computed property name
74977500
// class A { foo() { return "1" }}
@@ -8740,7 +8743,7 @@ func (c *Checker) chooseOverload(s *CallState, relation *Relation) *Signature {
87408743
if inferenceContext != nil {
87418744
inferredTypeParameters = inferenceContext.inferredTypeParameters
87428745
}
8743-
checkCandidate = c.getSignatureInstantiation(candidate, typeArgumentTypes, inferredTypeParameters)
8746+
checkCandidate = c.getSignatureInstantiation(candidate, typeArgumentTypes, ast.IsInJSFile(candidate.declaration), inferredTypeParameters)
87448747
// If the original signature has a generic rest type, instantiation may produce a
87458748
// signature with different arity and we need to perform another arity check.
87468749
if c.getNonArrayRestType(candidate) != nil && !c.hasCorrectArity(s.node, s.args, checkCandidate, s.signatureHelpTrailingComma) {
@@ -8762,7 +8765,7 @@ func (c *Checker) chooseOverload(s *CallState, relation *Relation) *Signature {
87628765
s.argCheckMode = CheckModeNormal
87638766
if inferenceContext != nil {
87648767
typeArgumentTypes := c.instantiateTypes(c.inferTypeArguments(s.node, candidate, s.args, s.argCheckMode, inferenceContext), inferenceContext.mapper)
8765-
checkCandidate = c.getSignatureInstantiation(candidate, typeArgumentTypes, inferenceContext.inferredTypeParameters)
8768+
checkCandidate = c.getSignatureInstantiation(candidate, typeArgumentTypes, ast.IsInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters)
87668769
// If the original signature has a generic rest type, instantiation may produce a
87678770
// signature with different arity and we need to perform another arity check.
87688771
if c.getNonArrayRestType(candidate) != nil && !c.hasCorrectArity(s.node, s.args, checkCandidate, s.signatureHelpTrailingComma) {
@@ -8908,8 +8911,9 @@ func (c *Checker) hasCorrectTypeArgumentArity(signature *Signature, typeArgument
89088911
}
89098912

89108913
func (c *Checker) checkTypeArguments(signature *Signature, typeArgumentNodes []*ast.Node, reportErrors bool, headMessage *diagnostics.Message) []*Type {
8914+
isJavaScript := ast.IsInJSFile(signature.declaration)
89118915
typeParameters := signature.typeParameters
8912-
typeArgumentTypes := c.fillMissingTypeArguments(core.Map(typeArgumentNodes, c.getTypeFromTypeNode), typeParameters, c.getMinTypeArgumentCount(typeParameters))
8916+
typeArgumentTypes := c.fillMissingTypeArguments(core.Map(typeArgumentNodes, c.getTypeFromTypeNode), typeParameters, c.getMinTypeArgumentCount(typeParameters), isJavaScript)
89138917
var mapper *TypeMapper
89148918
for i := range typeArgumentNodes {
89158919
// Debug.assert(typeParameters[i] != nil, "Should not call checkTypeArguments with too many type arguments")
@@ -10164,7 +10168,7 @@ func (c *Checker) getInstantiationExpressionType(exprType *Type, node *ast.Node)
1016410168
return core.SameMap(applicableSignatures, func(sig *Signature) *Signature {
1016510169
typeArgumentTypes := c.checkTypeArguments(sig, typeArguments.Nodes, true /*reportErrors*/, nil)
1016610170
if typeArgumentTypes != nil {
10167-
return c.getSignatureInstantiation(sig, typeArgumentTypes, nil)
10171+
return c.getSignatureInstantiation(sig, typeArgumentTypes, ast.IsInJSFile(sig.declaration), nil)
1016810172
}
1016910173
return sig
1017010174
})
@@ -18346,21 +18350,22 @@ func (c *Checker) getInstantiatedConstructorsForTypeArguments(t *Type, typeArgum
1834618350
typeArguments := core.Map(typeArgumentNodes, c.getTypeFromTypeNode)
1834718351
return core.SameMap(signatures, func(sig *Signature) *Signature {
1834818352
if len(sig.typeParameters) != 0 {
18349-
return c.getSignatureInstantiation(sig, typeArguments, nil)
18353+
return c.getSignatureInstantiation(sig, typeArguments, ast.IsInJSFile(location), nil)
1835018354
}
1835118355
return sig
1835218356
})
1835318357
}
1835418358

1835518359
func (c *Checker) getConstructorsForTypeArguments(t *Type, typeArgumentNodes []*ast.Node, location *ast.Node) []*Signature {
1835618360
typeArgCount := len(typeArgumentNodes)
18361+
isJavaScript := ast.IsInJSFile(location)
1835718362
return core.Filter(c.getSignaturesOfType(t, SignatureKindConstruct), func(sig *Signature) bool {
18358-
return typeArgCount >= c.getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= len(sig.typeParameters)
18363+
return isJavaScript || typeArgCount >= c.getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= len(sig.typeParameters)
1835918364
})
1836018365
}
1836118366

18362-
func (c *Checker) getSignatureInstantiation(sig *Signature, typeArguments []*Type, inferredTypeParameters []*Type) *Signature {
18363-
instantiatedSignature := c.getSignatureInstantiationWithoutFillingInTypeArguments(sig, c.fillMissingTypeArguments(typeArguments, sig.typeParameters, c.getMinTypeArgumentCount(sig.typeParameters)))
18367+
func (c *Checker) getSignatureInstantiation(sig *Signature, typeArguments []*Type, isJavaScript bool, inferredTypeParameters []*Type) *Signature {
18368+
instantiatedSignature := c.getSignatureInstantiationWithoutFillingInTypeArguments(sig, c.fillMissingTypeArguments(typeArguments, sig.typeParameters, c.getMinTypeArgumentCount(sig.typeParameters), isJavaScript))
1836418369
if len(inferredTypeParameters) != 0 {
1836518370
returnSignature := c.getSingleCallOrConstructSignature(c.getReturnTypeOfSignature(instantiatedSignature))
1836618371
if returnSignature != nil {
@@ -18498,12 +18503,13 @@ func (c *Checker) createCanonicalSignature(signature *Signature) *Signature {
1849818503
// where different generations of the same type parameter are in scope). This leads to a lot of new type
1849918504
// identities, and potentially a lot of work comparing those identities, so here we create an instantiation
1850018505
// that uses the original type identities for all unconstrained type parameters.
18501-
return c.getSignatureInstantiation(signature, core.Map(signature.typeParameters, func(tp *Type) *Type {
18506+
typeArguments := core.Map(signature.typeParameters, func(tp *Type) *Type {
1850218507
if tp.Target() != nil && c.getConstraintOfTypeParameter(tp.Target()) == nil {
1850318508
return tp.Target()
1850418509
}
1850518510
return tp
18506-
}), nil)
18511+
})
18512+
return c.getSignatureInstantiation(signature, typeArguments, ast.IsInJSFile(signature.declaration), nil /*inferredTypeParameters*/)
1850718513
}
1850818514

1850918515
func (c *Checker) getBaseSignature(signature *Signature) *Signature {
@@ -18563,7 +18569,7 @@ func (c *Checker) instantiateSignatureInContextOf(signature *Signature, contextu
1856318569
c.inferTypes(context.inferences, source, target, InferencePriorityReturnType, false)
1856418570
})
1856518571
}
18566-
return c.getSignatureInstantiation(signature, c.getInferredTypes(context), nil)
18572+
return c.getSignatureInstantiation(signature, c.getInferredTypes(context), ast.IsInJSFile(contextualSignature.declaration), nil /*inferredTypeParameters*/)
1856718573
}
1856818574

1856918575
func (c *Checker) resolveBaseTypesOfInterface(t *Type) {
@@ -19884,16 +19890,17 @@ func (c *Checker) getDefaultConstructSignatures(classType *Type) []*Signature {
1988419890
return []*Signature{c.newSignature(flags, nil, classType.AsInterfaceType().LocalTypeParameters(), nil, nil, classType, nil, 0)}
1988519891
}
1988619892
baseTypeNode := getBaseTypeNodeOfClass(classType)
19893+
isJavaScript := declaration != nil && ast.IsInJSFile(declaration)
1988719894
typeArguments := c.getTypeArgumentsFromNode(baseTypeNode)
1988819895
typeArgCount := len(typeArguments)
1988919896
var result []*Signature
1989019897
for _, baseSig := range baseSignatures {
1989119898
minTypeArgumentCount := c.getMinTypeArgumentCount(baseSig.typeParameters)
1989219899
typeParamCount := len(baseSig.typeParameters)
19893-
if typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount {
19900+
if isJavaScript || typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount {
1989419901
var sig *Signature
1989519902
if typeParamCount != 0 {
19896-
sig = c.createSignatureInstantiation(baseSig, c.fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount))
19903+
sig = c.createSignatureInstantiation(baseSig, c.fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript))
1989719904
} else {
1989819905
sig = c.cloneSignature(baseSig)
1989919906
}
@@ -20987,7 +20994,7 @@ func (c *Checker) getTypeArguments(t *Type) []*Type {
2098720994
}
2098820995

2098920996
func (c *Checker) getEffectiveTypeArguments(node *ast.Node, typeParameters []*Type) []*Type {
20990-
return c.fillMissingTypeArguments(core.Map(node.TypeArguments(), c.getTypeFromTypeNode), typeParameters, c.getMinTypeArgumentCount(typeParameters))
20997+
return c.fillMissingTypeArguments(core.Map(node.TypeArguments(), c.getTypeFromTypeNode), typeParameters, c.getMinTypeArgumentCount(typeParameters), ast.IsInJSFile(node))
2099120998
}
2099220999

2099321000
// Gets the minimum number of type arguments needed to satisfy all non-optional type parameters.
@@ -21007,32 +21014,45 @@ func (c *Checker) hasTypeParameterDefault(t *Type) bool {
2100721014
})
2100821015
}
2100921016

21010-
func (c *Checker) fillMissingTypeArguments(typeArguments []*Type, typeParameters []*Type, minTypeArgumentCount int) []*Type {
21017+
func (c *Checker) fillMissingTypeArguments(typeArguments []*Type, typeParameters []*Type, minTypeArgumentCount int, isJavaScriptImplicitAny bool) []*Type {
2101121018
numTypeParameters := len(typeParameters)
2101221019
if numTypeParameters == 0 {
2101321020
return nil
2101421021
}
2101521022
numTypeArguments := len(typeArguments)
21016-
if numTypeArguments >= minTypeArgumentCount && numTypeArguments < numTypeParameters {
21023+
if isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments < numTypeParameters) {
2101721024
result := make([]*Type, numTypeParameters)
2101821025
copy(result, typeArguments)
2101921026
// Map invalid forward references in default types to the error type
2102021027
for i := numTypeArguments; i < numTypeParameters; i++ {
2102121028
result[i] = c.errorType
2102221029
}
21030+
baseDefaultType := c.getDefaultTypeArgumentType(isJavaScriptImplicitAny)
2102321031
for i := numTypeArguments; i < numTypeParameters; i++ {
2102421032
defaultType := c.getDefaultFromTypeParameter(typeParameters[i])
21033+
21034+
if isJavaScriptImplicitAny && defaultType != nil && (c.isTypeIdenticalTo(defaultType, c.unknownType) || c.isTypeIdenticalTo(defaultType, c.emptyObjectType)) {
21035+
defaultType = c.anyType
21036+
}
21037+
2102521038
if defaultType != nil {
2102621039
result[i] = c.instantiateType(defaultType, newTypeMapper(typeParameters, result))
2102721040
} else {
21028-
result[i] = c.unknownType
21041+
result[i] = baseDefaultType
2102921042
}
2103021043
}
2103121044
return result
2103221045
}
2103321046
return typeArguments
2103421047
}
2103521048

21049+
func (c *Checker) getDefaultTypeArgumentType(isInJavaScriptFile bool) *Type {
21050+
if isInJavaScriptFile {
21051+
return c.anyType
21052+
}
21053+
return c.unknownType
21054+
}
21055+
2103621056
// Gets the default type for a type parameter. If the type parameter is the result of an instantiation,
2103721057
// this gets the instantiated default type of its target. If the type parameter has no default type or
2103821058
// the default is circular, `undefined` is returned.
@@ -22072,6 +22092,8 @@ func (c *Checker) getTypeReferenceType(node *ast.Node, symbol *ast.Symbol) *Type
2207222092
if res != nil && c.checkNoTypeArguments(node, symbol) {
2207322093
return c.getRegularTypeOfLiteralType(res)
2207422094
}
22095+
22096+
// !!! Resolving values as types for JS
2207522097
return c.errorType
2207622098
}
2207722099

@@ -22085,23 +22107,37 @@ func (c *Checker) getTypeFromClassOrInterfaceReference(node *ast.Node, symbol *a
2208522107
if len(typeParameters) != 0 {
2208622108
numTypeArguments := len(node.TypeArguments())
2208722109
minTypeArgumentCount := c.getMinTypeArgumentCount(typeParameters)
22088-
if numTypeArguments < minTypeArgumentCount || numTypeArguments > len(typeParameters) {
22089-
message := diagnostics.Generic_type_0_requires_1_type_argument_s
22090-
if minTypeArgumentCount < len(typeParameters) {
22091-
message = diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments
22110+
isJs := ast.IsInJSFile(node)
22111+
isJsImplicitAny := !c.noImplicitAny && isJs
22112+
if !isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > len(typeParameters)) {
22113+
var message *diagnostics.Message
22114+
22115+
missingAugmentsTag := isJs && ast.IsExpressionWithTypeArguments(node) && !ast.IsJSDocAugmentsTag(node.Parent)
22116+
if missingAugmentsTag {
22117+
message = diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag
22118+
if minTypeArgumentCount < len(typeParameters) {
22119+
message = diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag
22120+
}
22121+
} else {
22122+
message = diagnostics.Generic_type_0_requires_1_type_argument_s
22123+
if minTypeArgumentCount < len(typeParameters) {
22124+
message = diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments
22125+
}
2209222126
}
22093-
typeStr := c.TypeToString(t) // !!! /*enclosingDeclaration*/, nil, TypeFormatFlagsWriteArrayAsGenericType
22127+
typeStr := c.TypeToStringEx(t, nil /*enclosingDeclaration*/, TypeFormatFlagsWriteArrayAsGenericType)
2209422128
c.error(node, message, typeStr, minTypeArgumentCount, len(typeParameters))
22095-
// TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments)
22096-
return c.errorType
22129+
if !isJs {
22130+
// TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments)
22131+
return c.errorType
22132+
}
2209722133
}
2209822134
if node.Kind == ast.KindTypeReference && c.isDeferredTypeReferenceNode(node, numTypeArguments != len(typeParameters)) {
2209922135
return c.createDeferredTypeReference(t, node, nil /*mapper*/, nil /*alias*/)
2210022136
}
2210122137
// In a type reference, the outer type parameters of the referenced class or interface are automatically
2210222138
// supplied as type arguments and the type reference only specifies arguments for the local type parameters
2210322139
// of the class or interface.
22104-
localTypeArguments := c.fillMissingTypeArguments(c.getTypeArgumentsFromNode(node), typeParameters, minTypeArgumentCount)
22140+
localTypeArguments := c.fillMissingTypeArguments(c.getTypeArgumentsFromNode(node), typeParameters, minTypeArgumentCount, isJs)
2210522141
typeArguments := append(d.OuterTypeParameters(), localTypeArguments...)
2210622142
return c.createTypeReference(t, typeArguments)
2210722143
}
@@ -22542,7 +22578,7 @@ func (c *Checker) getTypeAliasInstantiation(symbol *ast.Symbol, typeArguments []
2254222578
key := getTypeAliasInstantiationKey(typeArguments, alias)
2254322579
instantiation := links.instantiations[key]
2254422580
if instantiation == nil {
22545-
mapper := newTypeMapper(typeParameters, c.fillMissingTypeArguments(typeArguments, typeParameters, c.getMinTypeArgumentCount(typeParameters)))
22581+
mapper := newTypeMapper(typeParameters, c.fillMissingTypeArguments(typeArguments, typeParameters, c.getMinTypeArgumentCount(typeParameters), ast.IsInJSFile(symbol.ValueDeclaration)))
2254622582
instantiation = c.instantiateTypeWithAlias(t, mapper, alias)
2254722583
links.instantiations[key] = instantiation
2254822584
}

internal/checker/inference.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ func (c *Checker) inferFromTypes(n *InferenceState, source *Type, target *Type)
8282
// Simply infer from source type arguments to target type arguments, with defaults applied.
8383
params := c.typeAliasLinks.Get(source.alias.symbol).typeParameters
8484
minParams := c.getMinTypeArgumentCount(params)
85-
sourceTypes := c.fillMissingTypeArguments(source.alias.typeArguments, params, minParams)
86-
targetTypes := c.fillMissingTypeArguments(target.alias.typeArguments, params, minParams)
85+
nodeIsInJsFile := ast.IsInJSFile(source.alias.symbol.ValueDeclaration)
86+
sourceTypes := c.fillMissingTypeArguments(source.alias.typeArguments, params, minParams, nodeIsInJsFile)
87+
targetTypes := c.fillMissingTypeArguments(target.alias.typeArguments, params, minParams, nodeIsInJsFile)
8788
c.inferFromTypeArguments(n, sourceTypes, targetTypes, c.getAliasVariances(source.alias.symbol))
8889
}
8990
// And if there weren't any type arguments, there's no reason to run inference as the types must be the same.

internal/checker/jsx.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -952,16 +952,16 @@ func (c *Checker) getJsxPropsTypeFromClassType(sig *Signature, context *ast.Node
952952
// Props is of type 'any' or unknown
953953
return attributesType
954954
}
955-
// Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
955+
// Normal case -- add in IntrinsicClassAttributes<T> and IntrinsicAttributes
956956
apparentAttributesType := attributesType
957957
intrinsicClassAttribs := c.getJsxType(JsxNames.IntrinsicClassAttributes, context)
958958
if !c.isErrorType(intrinsicClassAttribs) {
959959
typeParams := c.getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol)
960960
hostClassType := c.getReturnTypeOfSignature(sig)
961961
var libraryManagedAttributeType *Type
962962
if typeParams != nil {
963-
// apply JSX.IntrinsicClassElements<hostClassType, ...>
964-
inferredArgs := c.fillMissingTypeArguments([]*Type{hostClassType}, typeParams, c.getMinTypeArgumentCount(typeParams))
963+
// apply JSX.IntrinsicClassAttributes<hostClassType, ...>
964+
inferredArgs := c.fillMissingTypeArguments([]*Type{hostClassType}, typeParams, c.getMinTypeArgumentCount(typeParams), ast.IsInJSFile(context))
965965
libraryManagedAttributeType = c.instantiateType(intrinsicClassAttribs, newTypeMapper(typeParams, inferredArgs))
966966
} else {
967967
libraryManagedAttributeType = intrinsicClassAttribs
@@ -1008,29 +1008,29 @@ func (c *Checker) getJsxManagedAttributesFromLocatedAttributes(context *ast.Node
10081008
managedSym := c.getJsxLibraryManagedAttributes(ns)
10091009
if managedSym != nil {
10101010
ctorType := c.getStaticTypeOfReferencedJsxConstructor(context)
1011-
result := c.instantiateAliasOrInterfaceWithDefaults(managedSym, []*Type{ctorType, attributesType})
1011+
result := c.instantiateAliasOrInterfaceWithDefaults(managedSym, []*Type{ctorType, attributesType}, ast.IsInJSFile(context))
10121012
if result != nil {
10131013
return result
10141014
}
10151015
}
10161016
return attributesType
10171017
}
10181018

1019-
func (c *Checker) instantiateAliasOrInterfaceWithDefaults(managedSym *ast.Symbol, typeArguments []*Type) *Type {
1019+
func (c *Checker) instantiateAliasOrInterfaceWithDefaults(managedSym *ast.Symbol, typeArguments []*Type, inJavaScript bool) *Type {
10201020
declaredManagedType := c.getDeclaredTypeOfSymbol(managedSym)
10211021
// fetches interface type, or initializes symbol links type parmaeters
10221022
if managedSym.Flags&ast.SymbolFlagsTypeAlias != 0 {
10231023
params := c.typeAliasLinks.Get(managedSym).typeParameters
10241024
if len(params) >= len(typeArguments) {
1025-
args := c.fillMissingTypeArguments(typeArguments, params, len(typeArguments))
1025+
args := c.fillMissingTypeArguments(typeArguments, params, len(typeArguments), inJavaScript)
10261026
if len(args) == 0 {
10271027
return declaredManagedType
10281028
}
10291029
return c.getTypeAliasInstantiation(managedSym, args, nil)
10301030
}
10311031
}
10321032
if len(declaredManagedType.AsInterfaceType().TypeParameters()) >= len(typeArguments) {
1033-
args := c.fillMissingTypeArguments(typeArguments, declaredManagedType.AsInterfaceType().TypeParameters(), len(typeArguments))
1033+
args := c.fillMissingTypeArguments(typeArguments, declaredManagedType.AsInterfaceType().TypeParameters(), len(typeArguments), inJavaScript)
10341034
return c.createTypeReference(declaredManagedType, args)
10351035
}
10361036
return nil
@@ -1272,7 +1272,7 @@ func (c *Checker) getJsxElementTypeTypeAt(location *ast.Node) *Type {
12721272
if sym == nil {
12731273
return nil
12741274
}
1275-
t := c.instantiateAliasOrInterfaceWithDefaults(sym, nil)
1275+
t := c.instantiateAliasOrInterfaceWithDefaults(sym, nil, ast.IsInJSFile(location))
12761276
if t == nil || c.isErrorType(t) {
12771277
return nil
12781278
}

0 commit comments

Comments
 (0)