Skip to content

Commit d5e7e1c

Browse files
authored
fix: don't prefix undefined since it's a primitive (#302)
1 parent a91bd27 commit d5e7e1c

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
@@ -159,6 +159,21 @@ describe('utils', () => {
159159
}),
160160
).toEqual('Foo<A, B>');
161161
});
162+
163+
it('should convert a Promise<undefined>', () => {
164+
expect(
165+
utils.typify({
166+
collection: false,
167+
innerTypes: [
168+
{
169+
collection: false,
170+
type: 'undefined',
171+
},
172+
],
173+
type: 'Promise',
174+
}),
175+
).toEqual('Promise<undefined>');
176+
});
162177
});
163178

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

0 commit comments

Comments
 (0)