Skip to content

Commit

Permalink
fix: excludeNotDocumented incorrectly ignored some symbols
Browse files Browse the repository at this point in the history
Fixes #1465
  • Loading branch information
Gerrit0 committed Jan 16, 2021
1 parent 66c1652 commit 1d03d4b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/lib/converter/context.ts
Expand Up @@ -13,6 +13,7 @@ import {
import type { Converter } from "./converter";
import { isNamedNode } from "./utils/nodes";
import { ConverterEvents } from "./converter-events";
import { resolveAliasedSymbol } from "./utils/symbols";

/**
* The context describes the current state the converter is in.
Expand Down Expand Up @@ -161,13 +162,8 @@ export class Context {
return symbol;
}

resolveAliasedSymbol(symbol: ts.Symbol): ts.Symbol;
resolveAliasedSymbol(symbol: ts.Symbol | undefined): ts.Symbol | undefined;
resolveAliasedSymbol(symbol: ts.Symbol | undefined) {
while (symbol && ts.SymbolFlags.Alias & symbol.flags) {
symbol = this.checker.getAliasedSymbol(symbol);
}
return symbol;
resolveAliasedSymbol(symbol: ts.Symbol): ts.Symbol {
return resolveAliasedSymbol(symbol, this.checker);
}

createDeclarationReflection(
Expand Down
5 changes: 4 additions & 1 deletion src/lib/converter/converter.ts
Expand Up @@ -17,6 +17,7 @@ import { getCommonDirectory } from "../utils/fs";
import { createMinimatch } from "../utils/paths";
import { IMinimatch } from "minimatch";
import { hasFlag } from "../utils/enum";
import { resolveAliasedSymbol } from "./utils/symbols";

/**
* Compiles source files using TypeScript and converts compiler symbols to reflections.
Expand Down Expand Up @@ -360,7 +361,9 @@ export class Converter extends ChildableComponent<
this.excludeNotDocumented &&
// If the enum is included, we should include members even if not documented.
!hasFlag(symbol.flags, ts.SymbolFlags.EnumMember) &&
symbol.getDocumentationComment(checker).length === 0
resolveAliasedSymbol(symbol, checker).getDocumentationComment(
checker
).length === 0
) {
return true;
}
Expand Down
11 changes: 11 additions & 0 deletions src/lib/converter/utils/symbols.ts
@@ -0,0 +1,11 @@
import * as ts from "typescript";

export function resolveAliasedSymbol(
symbol: ts.Symbol,
checker: ts.TypeChecker
): ts.Symbol {
while (ts.SymbolFlags.Alias & symbol.flags) {
symbol = checker.getAliasedSymbol(symbol);
}
return symbol;
}
28 changes: 26 additions & 2 deletions src/test/converter/variables/specs.nodoc.json
Expand Up @@ -355,6 +355,29 @@
"kindString": "Module",
"flags": {},
"children": [
{
"id": 22,
"name": "objectLiteral",
"kind": 32,
"kindString": "Variable",
"flags": {
"isConst": true
},
"comment": {
"shortText": "An object literal."
},
"type": {
"type": "reflection",
"declaration": {
"id": 23,
"name": "__type",
"kind": 65536,
"kindString": "Type literal",
"flags": {}
}
},
"defaultValue": "..."
},
{
"id": 20,
"name": "typeLiteral",
Expand Down Expand Up @@ -383,13 +406,14 @@
"title": "Variables",
"kind": 32,
"children": [
22,
20
]
}
]
},
{
"id": 22,
"id": 24,
"name": "variable",
"kind": 1,
"kindString": "Module",
Expand All @@ -404,7 +428,7 @@
1,
15,
19,
22
24
]
}
]
Expand Down

0 comments on commit 1d03d4b

Please sign in to comment.