Skip to content

Commit

Permalink
fix: --expose all with generic types (#2009)
Browse files Browse the repository at this point in the history
* code

* feat: more tests

* removed other tests as they work but generate different results (as expected)
  • Loading branch information
arthurfiorette authored Jul 3, 2024
1 parent bb5de41 commit 08e49c6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Error/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class UnknownTypeError extends BaseError {
constructor(readonly type: BaseType) {
super({
code: 101,
messageText: `Unknown type "${type.getId()}"`,
messageText: `Unknown type "${type?.getId()}"`,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/InterfaceAndClassNodeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser {
if (ts.isConstructorDeclaration(member)) {
const params = member.parameters.filter((param) =>
ts.isParameterPropertyDeclaration(param, param.parent),
) as ts.ParameterPropertyDeclaration[];
);
members.push(...params);
} else if (ts.isPropertySignature(member) || ts.isPropertyDeclaration(member)) {
members.push(member);
Expand Down
4 changes: 2 additions & 2 deletions src/SchemaGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export class SchemaGenerator {
ts.isTypeAliasDeclaration(node)
) {
if (
this.config?.expose === "all" ||
(this.isExportType(node) && !this.isGenericType(node as ts.TypeAliasDeclaration))
(this.config?.expose === "all" || this.isExportType(node)) &&
!this.isGenericType(node as ts.TypeAliasDeclaration)
) {
allTypes.set(this.getFullName(node, typeChecker), node);
return;
Expand Down
1 change: 1 addition & 0 deletions test/valid-data-other.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe("valid-data-other", () => {
it("import-anonymous", assertValidSchema("import-anonymous", "MyObject"));

it("generic-simple", assertValidSchema("generic-simple", "MyObject"));
it("generic-simple", assertValidSchema("generic-simple", "*", { expose: "all" }));
it("generic-arrays", assertValidSchema("generic-arrays", "MyObject"));
it("generic-multiple", assertValidSchema("generic-multiple", "MyObject"));
it("generic-multiargs", assertValidSchema("generic-multiargs", "MyObject"));
Expand Down

0 comments on commit 08e49c6

Please sign in to comment.