@@ -6361,7 +6361,7 @@ namespace ts {
6361
6361
* @param typeParameters The requested type parameters.
6362
6362
* @param minTypeArgumentCount The minimum number of required type arguments.
6363
6363
*/
6364
- function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript? : boolean) {
6364
+ function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript: boolean) {
6365
6365
const numTypeParameters = length(typeParameters);
6366
6366
if (numTypeParameters) {
6367
6367
const numTypeArguments = length(typeArguments);
@@ -6622,7 +6622,7 @@ namespace ts {
6622
6622
return anyType;
6623
6623
}
6624
6624
6625
- function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript? : boolean): Signature {
6625
+ function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript: boolean): Signature {
6626
6626
typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript);
6627
6627
const instantiations = signature.instantiations || (signature.instantiations = createMap<Signature>());
6628
6628
const id = getTypeListId(typeArguments);
@@ -6661,7 +6661,10 @@ namespace ts {
6661
6661
// where different generations of the same type parameter are in scope). This leads to a lot of new type
6662
6662
// identities, and potentially a lot of work comparing those identities, so here we create an instantiation
6663
6663
// that uses the original type identities for all unconstrained type parameters.
6664
- return getSignatureInstantiation(signature, map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp));
6664
+ return getSignatureInstantiation(
6665
+ signature,
6666
+ map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp),
6667
+ isInJavaScriptFile(signature.declaration));
6665
6668
}
6666
6669
6667
6670
function getOrCreateTypeFromSignature(signature: Signature): ObjectType {
@@ -6843,7 +6846,7 @@ namespace ts {
6843
6846
const id = getTypeListId(typeArguments);
6844
6847
let instantiation = links.instantiations.get(id);
6845
6848
if (!instantiation) {
6846
- links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters)))));
6849
+ links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), isInJavaScriptFile(symbol.valueDeclaration) ))));
6847
6850
}
6848
6851
return instantiation;
6849
6852
}
@@ -13999,8 +14002,9 @@ namespace ts {
13999
14002
const instantiatedSignatures = [];
14000
14003
for (const signature of signatures) {
14001
14004
if (signature.typeParameters) {
14002
- const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0);
14003
- instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments));
14005
+ const isJavascript = isInJavaScriptFile(node);
14006
+ const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0, isJavascript);
14007
+ instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript));
14004
14008
}
14005
14009
else {
14006
14010
instantiatedSignatures.push(signature);
@@ -15257,7 +15261,7 @@ namespace ts {
15257
15261
if (!contextualMapper) {
15258
15262
inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), InferencePriority.ReturnType);
15259
15263
}
15260
- return getSignatureInstantiation(signature, getInferredTypes(context));
15264
+ return getSignatureInstantiation(signature, getInferredTypes(context), isInJavaScriptFile(contextualSignature.declaration) );
15261
15265
}
15262
15266
15263
15267
function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: ReadonlyArray<Expression>, excludeArgument: boolean[], context: InferenceContext): Type[] {
@@ -15292,7 +15296,7 @@ namespace ts {
15292
15296
// Above, the type of the 'value' parameter is inferred to be 'A'.
15293
15297
const contextualSignature = getSingleCallSignature(instantiatedType);
15294
15298
const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
15295
- getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) :
15299
+ getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, isInJavaScriptFile(node) )) :
15296
15300
instantiatedType;
15297
15301
const inferenceTargetType = getReturnTypeOfSignature(signature);
15298
15302
// Inferences made from return types have lower priority than all other inferences.
@@ -16008,8 +16012,9 @@ namespace ts {
16008
16012
candidate = originalCandidate;
16009
16013
if (candidate.typeParameters) {
16010
16014
let typeArgumentTypes: Type[];
16015
+ const isJavascript = isInJavaScriptFile(candidate.declaration);
16011
16016
if (typeArguments) {
16012
- typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters));
16017
+ typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript );
16013
16018
if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) {
16014
16019
candidateForTypeArgumentError = originalCandidate;
16015
16020
break;
@@ -16018,7 +16023,7 @@ namespace ts {
16018
16023
else {
16019
16024
typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext);
16020
16025
}
16021
- candidate = getSignatureInstantiation(candidate, typeArgumentTypes);
16026
+ candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript );
16022
16027
}
16023
16028
if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) {
16024
16029
candidateForArgumentError = candidate;
@@ -18782,7 +18787,7 @@ namespace ts {
18782
18787
const constraint = getConstraintOfTypeParameter(typeParameters[i]);
18783
18788
if (constraint) {
18784
18789
if (!typeArguments) {
18785
- typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount);
18790
+ typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, isInJavaScriptFile(typeArgumentNodes[i]) );
18786
18791
mapper = createTypeMapper(typeParameters, typeArguments);
18787
18792
}
18788
18793
const typeArgument = typeArguments[i];
0 commit comments