fix(51868): this within function typed as any when annotated with JSDoc (#54516)

This commit is contained in:
Oleksandr T
2023-06-27 01:00:10 +03:00
committed by GitHub
parent 38575dc015
commit df40c7ae88
5 changed files with 246 additions and 10 deletions

View File

@@ -28473,20 +28473,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
function getTypeForThisExpressionFromJSDoc(node: Node) {
const jsdocType = getJSDocType(node);
if (jsdocType && jsdocType.kind === SyntaxKind.JSDocFunctionType) {
const jsDocFunctionType = jsdocType as JSDocFunctionType;
if (jsDocFunctionType.parameters.length > 0 &&
jsDocFunctionType.parameters[0].name &&
(jsDocFunctionType.parameters[0].name as Identifier).escapedText === InternalSymbolName.This) {
return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type!);
}
}
function getTypeForThisExpressionFromJSDoc(node: SignatureDeclaration) {
const thisTag = getJSDocThisTag(node);
if (thisTag && thisTag.typeExpression) {
return getTypeFromTypeNode(thisTag.typeExpression);
}
const signature = getSignatureOfTypeTag(node);
if (signature) {
return getThisTypeOfSignature(signature);
}
}
function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean {