Skip to content

Commit

Permalink
Fix constructor signature validation
Browse files Browse the repository at this point in the history
Resolves #2553
  • Loading branch information
Gerrit0 committed Apr 27, 2024
1 parent 95bf5d0 commit cf3dcd1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Types rendered in the `Returns` header are now properly colored, #2546.
- Links added with the `navigationLinks` option are now moved into the pull out navigation on mobile displays, #2548.
- `@license` and `@import` comments will be ignored at the top of files, #2552.
- Fixed issue in documentation validation where constructor signatures where improperly considered not documented, #2553.

### Thanks!

Expand Down
9 changes: 9 additions & 0 deletions src/lib/validation/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ export function validateDocumentation(
continue;
}

// Call signatures are considered documented if they are directly within a documented type alias.
if (
ref.kindOf(ReflectionKind.ConstructorSignature) &&
ref.parent?.parent?.kindOf(ReflectionKind.TypeAlias)
) {
toProcess.push(ref.parent.parent);
continue;
}

if (ref instanceof DeclarationReflection) {
const signatures =
ref.type instanceof ReflectionType
Expand Down
16 changes: 16 additions & 0 deletions src/test/converter2/issues/gh2553.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Constructor.
*
* @param args - Constructor arguments.
* @returns New instance.
*/
export type Constructor = new (...args: any[]) => object;

/**
* Typed constructor.
*
* @typeParam T - Class type.
* @param args - Constructor arguments.
* @returns New instance.
*/
export type TypedConstructor<T> = new (...args: any[]) => T;
6 changes: 6 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1438,4 +1438,10 @@ describe("Issue Tests", () => {
"This is an awesome module.",
);
});

it("Does not warn about documented constructor signature type aliases, #2553", () => {
const project = convert();
app.validate(project);
logger.expectNoOtherMessages();
});
});

0 comments on commit cf3dcd1

Please sign in to comment.