mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
fix(51868): this within function typed as any when annotated with JSDoc (#54516)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user