Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access type interfaces from the browser API as @types/chrome. #1213

Open
Tracked by #1085
1natsu172 opened this issue Nov 26, 2024 · 2 comments
Open
Tracked by #1085

Comments

@1natsu172
Copy link
Contributor

1natsu172 commented Nov 26, 2024

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-polyfill
function handler1(params: Runtime.MessageSender) {}

// This types from @types/chrome(need install `@types/chrome`)
function handler2(params: chrome.runtime.MessageSender) {}

Originally posted by @1natsu172 in #1116 (comment)

and

Originally posted in #1116 (comment)

@1natsu172
Copy link
Contributor Author

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
Copy link
Collaborator

Yeah, is this just how @types/chrome works. I have a section on using its types in the docs here:

https://wxt.dev/guide/essentials/extension-apis.html#disabling-the-polyfill

@aklinker1 aklinker1 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2024
@aklinker1 aklinker1 reopened this Dec 31, 2024
@aklinker1 aklinker1 mentioned this issue Dec 31, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants