Skip to content

Commit 057357b

Browse files
author
zhengbli
committed
CR feedback
1 parent 03dcdda commit 057357b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/services/services.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4913,22 +4913,24 @@ namespace ts {
49134913

49144914
if (!documentation) {
49154915
documentation = symbol.getDocumentationComment();
4916-
if ((!documentation || documentation.length === 0) && symbol.flags & SymbolFlags.Property) {
4916+
if (documentation.length === 0 && symbol.flags & SymbolFlags.Property) {
49174917
// For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo`
49184918
// there documentation comments might be attached to the right hand side symbol of their declarations.
49194919
// The pattern of such special property access is that the parent symbol is the symbol of the file.
49204920
if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) {
4921-
forEach(symbol.declarations, declaration => {
4922-
if (declaration.parent && declaration.parent.kind === SyntaxKind.BinaryExpression) {
4923-
const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((<BinaryExpression>declaration.parent).right);
4924-
if (rhsSymbol) {
4925-
documentation = rhsSymbol.getDocumentationComment();
4926-
if (documentation && documentation.length > 0) {
4927-
return true;
4928-
}
4921+
for(const declaration of symbol.declarations) {
4922+
if (!declaration.parent || declaration.parent.kind !== SyntaxKind.BinaryExpression) {
4923+
continue;
4924+
}
4925+
4926+
const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((<BinaryExpression>declaration.parent).right);
4927+
if (rhsSymbol) {
4928+
documentation = rhsSymbol.getDocumentationComment();
4929+
if (documentation.length > 0) {
4930+
return;
49294931
}
49304932
}
4931-
});
4933+
}
49324934
}
49334935
}
49344936
}

0 commit comments

Comments
 (0)