diff --git a/src/lib/converter/converter.ts b/src/lib/converter/converter.ts index 8c015a922..4aae0dea9 100644 --- a/src/lib/converter/converter.ts +++ b/src/lib/converter/converter.ts @@ -40,6 +40,7 @@ export class Converter extends ChildableComponent< @BindOption("externalPattern") externalPattern!: string[]; private externalPatternCache?: IMinimatch[]; + private excludeCache?: IMinimatch[]; @BindOption("excludeExternals") excludeExternals!: boolean; @@ -384,6 +385,10 @@ export class Converter extends ChildableComponent< return true; } + if (this.isExcluded(symbol)) { + return true; + } + if (!this.excludeExternals) { return false; } @@ -391,6 +396,22 @@ export class Converter extends ChildableComponent< return this.isExternal(symbol); } + private isExcluded(symbol: ts.Symbol) { + this.excludeCache ??= createMinimatch(this.application.exclude); + + for (const node of symbol.getDeclarations() ?? []) { + if ( + this.excludeCache.some((p) => + p.match(node.getSourceFile().fileName) + ) + ) { + return true; + } + } + + return false; + } + /** @internal */ isExternal(symbol: ts.Symbol) { this.externalPatternCache ??= createMinimatch(this.externalPattern); diff --git a/src/test/converter2.test.ts b/src/test/converter2.test.ts index 583cd9191..71ec8724c 100644 --- a/src/test/converter2.test.ts +++ b/src/test/converter2.test.ts @@ -186,6 +186,14 @@ const issueTests: Record void> = { equal(query(project, "emptyObj").defaultValue, "{}"); equal(query(project, "nonEmptyObj").defaultValue, "..."); }, + + gh1578(project) { + ok(query(project, "notIgnored")); + ok( + !project.findReflectionByName("ignored"), + "Symbol re-exported from ignored file is ignored." + ); + }, }; describe("Converter2", () => { @@ -221,7 +229,7 @@ describe("Converter2", () => { join(base, "issues", `${entry}.d.ts`), join(base, "issues", `${entry}.tsx`), join(base, "issues", `${entry}.js`), - join(base, "issues", entry), + join(base, "issues", entry, "index.ts"), ].find(existsSync); ok(entryPoint, `No entry point found for ${entry}`); diff --git a/src/test/converter2/issues/gh1578/ignored.ts b/src/test/converter2/issues/gh1578/ignored.ts new file mode 100644 index 000000000..1c4e8aea0 --- /dev/null +++ b/src/test/converter2/issues/gh1578/ignored.ts @@ -0,0 +1 @@ +export const ignored = true; diff --git a/src/test/converter2/issues/gh1578/index.ts b/src/test/converter2/issues/gh1578/index.ts new file mode 100644 index 000000000..c003a7b47 --- /dev/null +++ b/src/test/converter2/issues/gh1578/index.ts @@ -0,0 +1,2 @@ +export { ignored } from "./ignored"; +export const notIgnored = true; diff --git a/src/test/converter2/tsconfig.json b/src/test/converter2/tsconfig.json index 9b0acb858..674d64473 100644 --- a/src/test/converter2/tsconfig.json +++ b/src/test/converter2/tsconfig.json @@ -8,5 +8,8 @@ // See #1524. We might force this to false eventually. "skipLibCheck": true + }, + "typedocOptions": { + "exclude": ["**/ignored.ts"] } }