Avoid pulling on setter type when only getter type is needed to break circularity (#47818)

This commit is contained in:
Andrew Branch
2022-02-09 10:56:29 -08:00
committed by GitHub
parent c06849ad16
commit 2cf5afd49e
5 changed files with 109 additions and 4 deletions

View File

@@ -9511,11 +9511,12 @@ namespace ts {
const getter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.GetAccessor);
const setter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.SetAccessor);
const setterType = getAnnotatedAccessorType(setter);
// For write operations, prioritize type annotations on the setter
if (writing && setterType) {
return instantiateTypeIfNeeded(setterType, symbol);
if (writing) {
const setterType = getAnnotatedAccessorType(setter);
if (setterType) {
return instantiateTypeIfNeeded(setterType, symbol);
}
}
// Else defer to the getter type
@@ -9533,6 +9534,7 @@ namespace ts {
}
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
const setterType = getAnnotatedAccessorType(setter);
if (setterType) {
return setterType;
}