From e7384d109b23f3cc737ba5a7b459a104a767eafb Mon Sep 17 00:00:00 2001 From: David Sanders Date: Mon, 25 Aug 2025 23:22:29 -0700 Subject: [PATCH] fix: don't inappropriately prefix if promise has multiple inner types --- src/utils.ts | 2 +- test/utils.spec.ts | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 2620630..12f33b5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -100,7 +100,7 @@ const prefixTypeForSafety = (type: string) => { typeof type === 'string' && !isPrimitive(type) && !isBuiltIn(type) && - !/\(\| /gi.test(type) + !/[\(\| ]/gi.test(type) ) { return `Electron.${type}`; } diff --git a/test/utils.spec.ts b/test/utils.spec.ts index fd7e7e4..7ba9128 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -104,6 +104,30 @@ describe('utils', () => { expect(utils.typify('buffer')).toEqual('Buffer'); }); + it('should convert a promise with multiple inner types', () => { + expect( + utils.typify({ + collection: false, + innerTypes: [ + { + collection: false, + type: [ + { + collection: false, + type: 'number', + }, + { + collection: false, + type: 'null', + }, + ], + }, + ], + type: 'Promise', + }), + ).toEqual('Promise<(number) | (null)>'); + }); + it('should convert custom types with inner types', () => { expect( utils.typify({