Skip to content

Commit c8cd748

Browse files
committed
Handle JSDoc tags on 'this' properties
1 parent cbc112a commit c8cd748

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,14 @@ namespace ts {
29372937
}
29382938
// Handle module.exports = expr
29392939
if (declaration.kind === SyntaxKind.BinaryExpression) {
2940+
// Use JS Doc type if present on parent expression statement
2941+
if (declaration.flags & NodeFlags.JavaScriptFile) {
2942+
const typeTag = getJSDocTypeTag(declaration.parent);
2943+
if (typeTag && typeTag.typeExpression) {
2944+
return links.type = getTypeFromTypeNode(typeTag.typeExpression.type);
2945+
}
2946+
}
2947+
29402948
return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
29412949
}
29422950
if (declaration.kind === SyntaxKind.PropertyAccessExpression) {

0 commit comments

Comments
 (0)