You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot access type interfaces from the browser API as @types/chrome. #1213
The second thing is that the interface as a type cannot be inferred from the browser as you say. This one is not a package-manager dependent problem. I think it's an implementation glitch in WXT.
The workaround over here is below, and either approach should be used.
import{Runtime}from"wxt/browser";// This types from webextension-polyfillfunctionhandler1(params: Runtime.MessageSender){}// This types from @types/chrome(need install `@types/chrome`)functionhandler2(params: chrome.runtime.MessageSender){}
After some investigation, it seems this might be more of an issue with the upstream type definitions rather than WXT itself. Since the interfaces are defined alongside the implementation within a namespace, there is no way to re-export them.
Activity
1natsu172 commentedon Nov 26, 2024
After some investigation, it seems this might be more of an issue with the upstream type definitions rather than WXT itself. Since the interfaces are defined alongside the implementation within a namespace, there is no way to re-export them.
aklinker1 commentedon Nov 26, 2024
Yeah, is this just how
@types/chromeworks. I have a section on using its types in the docs here:https://wxt.dev/guide/essentials/extension-apis.html#disabling-the-polyfill
aklinker1 commentedon Mar 28, 2025
Released in v0.20.0. Use the
Browsernamespace instead ofchrometo access types.https://wxt.dev/guide/essentials/extension-apis.html#accessing-types