This commit is contained in:
zhengbli 2016-08-19 15:48:46 -07:00
Родитель 03dcdda443
Коммит 057357be88
1 изменённых файлов: 12 добавлений и 10 удалений

Просмотреть файл

@ -4913,22 +4913,24 @@ namespace ts {
if (!documentation) {
documentation = symbol.getDocumentationComment();
if ((!documentation || documentation.length === 0) && symbol.flags & SymbolFlags.Property) {
if (documentation.length === 0 && symbol.flags & SymbolFlags.Property) {
// For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo`
// there documentation comments might be attached to the right hand side symbol of their declarations.
// The pattern of such special property access is that the parent symbol is the symbol of the file.
if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) {
forEach(symbol.declarations, declaration => {
if (declaration.parent && declaration.parent.kind === SyntaxKind.BinaryExpression) {
const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((<BinaryExpression>declaration.parent).right);
if (rhsSymbol) {
documentation = rhsSymbol.getDocumentationComment();
if (documentation && documentation.length > 0) {
return true;
}
for(const declaration of symbol.declarations) {
if (!declaration.parent || declaration.parent.kind !== SyntaxKind.BinaryExpression) {
continue;
}
const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((<BinaryExpression>declaration.parent).right);
if (rhsSymbol) {
documentation = rhsSymbol.getDocumentationComment();
if (documentation.length > 0) {
return;
}
}
});
}
}
}
}