diff --git a/.config/mocha.fast.json b/.config/mocha.fast.json index d546079ba..922306dfc 100644 --- a/.config/mocha.fast.json +++ b/.config/mocha.fast.json @@ -1,5 +1,8 @@ { + "$schema": "https://json.schemastore.org/mocharc.json", "timeout": 5000, "spec": ["src/test/**/*.test.ts"], - "exclude": ["src/test/packages/**", "src/test/slow/**"] + "exclude": ["src/test/packages/**", "src/test/slow/**"], + "watch-files": ["src/**/*.ts"], + "extension": ["ts", "tsx"] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 83db0f377..95a4b1d25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Search results will no longer include random items when the search bar is empty, #1881. - Comments on overloaded constructors will now be detected in the same way that overloaded functions/methods are. - Fixed `removeReflection` not completely removing reflections from the project, #1898. +- Fixed `@hidden` / `@ignore` / `@exclude` comments on default exports with no associated variable, #1903. ### Thanks! diff --git a/src/lib/converter/plugins/CommentPlugin.ts b/src/lib/converter/plugins/CommentPlugin.ts index 039c9f667..fb260f34e 100644 --- a/src/lib/converter/plugins/CommentPlugin.ts +++ b/src/lib/converter/plugins/CommentPlugin.ts @@ -281,9 +281,9 @@ export class CommentPlugin extends ConverterComponent { ) as DeclarationReflection[], (method) => method.signatures?.length === 0 ); - allRemoved.forEach((reflection) => - project.removeReflection(reflection) - ); + allRemoved.forEach((reflection) => { + project.removeReflection(reflection); + }); someRemoved.forEach((reflection) => { reflection.sources = unique( reflection.signatures!.reduce( diff --git a/src/lib/converter/symbols.ts b/src/lib/converter/symbols.ts index 19d96f5d1..348a34722 100644 --- a/src/lib/converter/symbols.ts +++ b/src/lib/converter/symbols.ts @@ -170,6 +170,18 @@ export function convertSymbol( flags = removeFlag(flags, ts.SymbolFlags.Property); } + // A default exported function with no associated variable is a property, but + // we should really convert it as a variable for documentation purposes + // export default () => {} + // export default 123 + if ( + flags === ts.SymbolFlags.Property && + symbol.name === "default" && + context.scope.kindOf(ReflectionKind.Module | ReflectionKind.Project) + ) { + flags = ts.SymbolFlags.BlockScopedVariable; + } + for (const flag of getEnumFlags(flags ^ allConverterFlags)) { if (!(flag & allConverterFlags)) { context.logger.verbose( @@ -178,8 +190,8 @@ export function convertSymbol( } } - // Note: This method does not allow skipping earlier converters, defined according to the order of - // the ts.SymbolFlags enum. For now, this is fine... might not be flexible enough in the future. + // Note: This method does not allow skipping earlier converters. + // For now, this is fine... might not be flexible enough in the future. let skip = 0; for (const flag of conversionOrder) { if (!(flag & flags)) continue; diff --git a/src/test/converter2/issues/gh1903.ts b/src/test/converter2/issues/gh1903.ts new file mode 100644 index 000000000..c95663935 --- /dev/null +++ b/src/test/converter2/issues/gh1903.ts @@ -0,0 +1,4 @@ +/** + * @hidden + */ +export default () => {}; diff --git a/src/test/issueTests.ts b/src/test/issueTests.ts index 7b5707450..86e0f5e1d 100644 --- a/src/test/issueTests.ts +++ b/src/test/issueTests.ts @@ -356,4 +356,11 @@ export const issueTests: { ); logger.expectNoOtherMessages(); }, + + gh1903(project) { + equal( + Object.values(project.reflections).map((r) => r.name), + ["typedoc"] + ); + }, };