From 0fa5086da4e3c6c5b578072f94b00c576fdc3017 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 12 Jun 2023 11:22:44 -0700 Subject: [PATCH] Revert "fix: do not prefix promise inner types (#227)" This reverts commit 9560079845b53c3ebf38d9a3bb8f2ff135072718. --- src/utils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 2c34662..b93bfb3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -95,6 +95,13 @@ export const wrapComment = (comment: string, additionalTags: DocumentationTag[] return result.concat(' */'); }; +const prefixTypeForSafety = (type: string) => { + if (type !== 'Object' && typeof type === 'string' && !isPrimitive(type) && !isBuiltIn(type)) { + return `Electron.${type}`; + } + return type; +}; + export const typify = ( type: TypeInformation | TypeInformation[], maybeInnerReturnTypeName?: string, @@ -211,7 +218,7 @@ export const typify = ( return '(() => void)'; case 'promise': if (innerTypes) { - return `Promise<${typify(innerTypes[0])}>`; + return `Promise<${prefixTypeForSafety(typify(innerTypes[0]))}>`; } throw new Error('Promise with missing inner type'); case 'record':