Fix callback return type annotation before constructor (#54034)

This commit is contained in:
Nathan Shively-Sanders
2023-04-26 13:46:55 -07:00
committed by GitHub
parent 2cbfb51ebb
commit 1577535205
5 changed files with 111 additions and 2 deletions

View File

@@ -14818,16 +14818,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (declaration.kind === SyntaxKind.Constructor) {
return getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent as ClassDeclaration).symbol));
}
const typeNode = getEffectiveReturnTypeNode(declaration);
if (isJSDocSignature(declaration)) {
const root = getJSDocRoot(declaration);
if (root && isConstructorDeclaration(root.parent)) {
if (root && isConstructorDeclaration(root.parent) && !typeNode) {
return getDeclaredTypeOfClassOrInterface(getMergedSymbol((root.parent.parent as ClassDeclaration).symbol));
}
}
if (isJSDocConstructSignature(declaration)) {
return getTypeFromTypeNode((declaration.parameters[0] as ParameterDeclaration).type!); // TODO: GH#18217
}
const typeNode = getEffectiveReturnTypeNode(declaration);
if (typeNode) {
return getTypeFromTypeNode(typeNode);
}