Skip to content

Commit ad56220

Browse files
committed
Instantiate contextual this parameters if needed
1 parent f9d2937 commit ad56220

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,6 +4632,9 @@ namespace ts {
46324632

46334633
function getThisTypeOfSignature(signature: Signature): Type | undefined {
46344634
if (signature.thisParameter) {
4635+
if (signature.mapper) {
4636+
signature = instantiateSignature(signature, signature.mapper);
4637+
}
46354638
return getTypeOfSymbol(signature.thisParameter);
46364639
}
46374640
}
@@ -11770,6 +11773,10 @@ namespace ts {
1177011773

1177111774
function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) {
1177211775
const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0);
11776+
if (context.thisParameter) {
11777+
// save the mapper in case we need to type `this` later
11778+
context.mapper = mapper;
11779+
}
1177311780
for (let i = 0; i < len; i++) {
1177411781
const parameter = signature.parameters[i];
1177511782
const contextualParameterType = getTypeAtPosition(context, i);

0 commit comments

Comments
 (0)