Skip to content

Commit 34c248a

Browse files
committed
fix: don't prefix undefined since it's a primitive
1 parent f6db74a commit 34c248a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export const isEmitter = (doc: ParsedDocumentationResult[0]) => {
293293
return false;
294294
};
295295
export const isPrimitive = (type: string) => {
296-
const primitives = ['boolean', 'number', 'any', 'string', 'void', 'null', 'unknown'];
296+
const primitives = ['boolean', 'number', 'any', 'string', 'void', 'null', 'unknown', 'undefined'];
297297
return primitives.indexOf(type.toLowerCase().replace(/\[\]/g, '')) !== -1;
298298
};
299299
export const isBuiltIn = (type: string) => {

test/utils.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,21 @@ describe('utils', () => {
135135
}),
136136
).toEqual('Foo<A, B>');
137137
});
138+
139+
it('should convert a Promise<undefined>', () => {
140+
expect(
141+
utils.typify({
142+
collection: false,
143+
innerTypes: [
144+
{
145+
collection: false,
146+
type: 'undefined',
147+
},
148+
],
149+
type: 'Promise',
150+
}),
151+
).toEqual('Promise<undefined>');
152+
});
138153
});
139154

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

0 commit comments

Comments
 (0)