Skip to content

Commit e7384d1

Browse files
committed
fix: don't inappropriately prefix if promise has multiple inner types
1 parent f6db74a commit e7384d1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const prefixTypeForSafety = (type: string) => {
100100
typeof type === 'string' &&
101101
!isPrimitive(type) &&
102102
!isBuiltIn(type) &&
103-
!/\(\| /gi.test(type)
103+
!/[\(\| ]/gi.test(type)
104104
) {
105105
return `Electron.${type}`;
106106
}

test/utils.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,30 @@ describe('utils', () => {
104104
expect(utils.typify('buffer')).toEqual('Buffer');
105105
});
106106

107+
it('should convert a promise with multiple inner types', () => {
108+
expect(
109+
utils.typify({
110+
collection: false,
111+
innerTypes: [
112+
{
113+
collection: false,
114+
type: [
115+
{
116+
collection: false,
117+
type: 'number',
118+
},
119+
{
120+
collection: false,
121+
type: 'null',
122+
},
123+
],
124+
},
125+
],
126+
type: 'Promise',
127+
}),
128+
).toEqual('Promise<(number) | (null)>');
129+
});
130+
107131
it('should convert custom types with inner types', () => {
108132
expect(
109133
utils.typify({

0 commit comments

Comments
 (0)