Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ export const typify = (
// we'll have to qualify it with the Node.js namespace.
return 'NodeJS.ReadableStream';
}
// Custom type
if (innerTypes) return `${typeAsString}<${typify(innerTypes[0])}>`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

innerTypes is an array, we should technically do this for any number of inner types not just the first one. E.g. Foo<T, R> should be supported (I think the docs parser will read this)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed. I tested with docs-parser and received multiple innerTypes (nice work btw!)

return typeAsString;
};
export const paramify = (paramName: string) => {
Expand Down
15 changes: 15 additions & 0 deletions test/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ describe('utils', () => {
it('should map node objects to the correct type', () => {
expect(utils.typify('buffer')).toEqual('Buffer');
});

it('should convert custom types with inner types', () => {
expect(
utils.typify({
collection: false,
innerTypes: [
{
collection: false,
type: 'T',
},
],
type: 'Foo',
}),
).toEqual('Foo<T>');
});
});

describe('paramify', () => {
Expand Down