mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 22:51:17 -05:00
Assign and instantiate contextual this type if not present
This commit is contained in:
@@ -4785,9 +4785,6 @@ namespace ts {
|
||||
|
||||
function getThisTypeOfSignature(signature: Signature): Type | undefined {
|
||||
if (signature.thisParameter) {
|
||||
if (signature.mapper) {
|
||||
signature = instantiateSignature(signature, signature.mapper);
|
||||
}
|
||||
return getTypeOfSymbol(signature.thisParameter);
|
||||
}
|
||||
}
|
||||
@@ -9085,15 +9082,15 @@ namespace ts {
|
||||
return getInferredClassType(classSymbol);
|
||||
}
|
||||
}
|
||||
const type = getContextuallyTypedThisType(container);
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
|
||||
const thisType = getThisTypeOfDeclaration(container);
|
||||
if (thisType) {
|
||||
return thisType;
|
||||
}
|
||||
const type = getContextuallyTypedThisType(container);
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
if (isClassLike(container.parent)) {
|
||||
const symbol = getSymbolOfNode(container.parent);
|
||||
@@ -12277,8 +12274,10 @@ namespace ts {
|
||||
function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) {
|
||||
const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0);
|
||||
if (context.thisParameter) {
|
||||
// save the mapper in case we need to type `this` later
|
||||
context.mapper = mapper;
|
||||
if (!signature.thisParameter) {
|
||||
signature.thisParameter = createTransientSymbol(context.thisParameter, undefined);
|
||||
}
|
||||
assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper);
|
||||
}
|
||||
for (let i = 0; i < len; i++) {
|
||||
const parameter = signature.parameters[i];
|
||||
|
||||
Reference in New Issue
Block a user