diff --git a/src/utils.ts b/src/utils.ts index 4e5ed30..ddc87ef 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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) => { diff --git a/test/utils.spec.ts b/test/utils.spec.ts index e8a29e9..733887f 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -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'); + + expect( + utils.typify({ + collection: false, + innerTypes: [ + { + collection: false, + type: 'A', + }, + { + collection: false, + type: 'B', + }, + ], + type: 'Foo', + }), + ).toEqual('Foo'); + }); }); describe('paramify', () => {