Skip to content

Commit 9a11301

Browse files
committed
feat: allow custom types with inner types
1 parent 576cb5e commit 9a11301

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ export const typify = (
255255
// we'll have to qualify it with the Node.js namespace.
256256
return 'NodeJS.ReadableStream';
257257
}
258+
// Custom type
259+
if (innerTypes) return `${typeAsString}<${typify(innerTypes[0])}>`;
258260
return typeAsString;
259261
};
260262
export const paramify = (paramName: string) => {

test/utils.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ describe('utils', () => {
102102
it('should map node objects to the correct type', () => {
103103
expect(utils.typify('buffer')).toEqual('Buffer');
104104
});
105+
106+
it('should convert custom types with inner types', () => {
107+
expect(
108+
utils.typify({
109+
collection: false,
110+
innerTypes: [
111+
{
112+
collection: false,
113+
type: 'T',
114+
},
115+
],
116+
type: 'Foo',
117+
}),
118+
).toEqual('Foo<T>');
119+
});
105120
});
106121

107122
describe('paramify', () => {

0 commit comments

Comments
 (0)