diff --git a/src/api/scripting/methods.ts b/src/api/scripting/methods.ts index 2f5e9a4..38c3d88 100644 --- a/src/api/scripting/methods.ts +++ b/src/api/scripting/methods.ts @@ -1,7 +1,8 @@ import {browser} from "../browser"; import {callWithPromise} from "../utils"; -type Awaited = chrome.scripting.Awaited; +// Keep the result type independent of the removed chrome.scripting.Awaited alias. +type Awaited = T extends PromiseLike ? U : T; type ContentScriptFilter = chrome.scripting.ContentScriptFilter; type CSSInjection = chrome.scripting.CSSInjection; type InjectionResult = chrome.scripting.InjectionResult; diff --git a/tests/consumer-types/scripting-methods-types.ts b/tests/consumer-types/scripting-methods-types.ts index ae0da45..320bd57 100644 --- a/tests/consumer-types/scripting-methods-types.ts +++ b/tests/consumer-types/scripting-methods-types.ts @@ -1,6 +1,6 @@ import {executeScript, getRegisteredContentScripts, insertCss, registerContentScripts, removeCss, unregisterContentScripts, updateContentScripts} from "@addon-core/browser"; -type Awaited = chrome.scripting.Awaited; +type Awaited = T extends PromiseLike ? U : T; type ContentScriptFilter = chrome.scripting.ContentScriptFilter; type CSSInjection = chrome.scripting.CSSInjection; type InjectionResult = chrome.scripting.InjectionResult; @@ -20,8 +20,12 @@ type Expected = { }; type Equal = (() => T extends A ? 1 : 2) extends (() => T extends B ? 1 : 2) ? true : false; -const signaturesUnchanged: Equal = true; -void [methods, signaturesUnchanged]; +const signaturesUnchanged: Equal, Omit> = true; +// Conditional result aliases from different declaration files need assignability checks. +const compatibleExecuteScript: Expected["executeScript"] = executeScript; +declare const expectedExecuteScript: Expected["executeScript"]; +const compatibleExpected: typeof executeScript = expectedExecuteScript; +void [methods, signaturesUnchanged, compatibleExecuteScript, compatibleExpected]; const pending: Promise[]> = executeScript>({target: {tabId: 7}, func: async () => 42}); void pending;