Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ export const typify = (
// we'll have to qualify it with the Node.js namespace.
return 'NodeJS.ReadableStream';
}
// Custom type
if (innerTypes)
return `${typeAsString}<${innerTypes.map((innerType) => typify(innerType)).join(', ')}>`;
return typeAsString;
};
export const paramify = (paramName: string) => {
Expand Down
32 changes: 32 additions & 0 deletions test/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,38 @@ 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>');

expect(
utils.typify({
collection: false,
innerTypes: [
{
collection: false,
type: 'A',
},
{
collection: false,
type: 'B',
},
],
type: 'Foo',
}),
).toEqual('Foo<A, B>');
});
});

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