antfu-collective / vitesse-webext

⚡️ WebExtension Vite Starter Template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[issue] - type of 'browser' is any

hnbnh opened this issue · comments

Hi, there's a problem with browser variable, its type should not be any.

Steps to Reproduce

  1. Clone the project & install dependencies.
  2. Run pnpm dev.
  3. Content of src/auto-imports.d.ts:
declare global {
  const browser: typeof import('webextension-polyfill')['default']
  // ...
}
  1. The type of every browser variable is any.

I just ran into the same problem. The webextension-polyfill package exports a Browser type, so you can do this:

-  const browser: typeof import('webextension-polyfill')['default']
+  const browser: import("webextension-polyfill").Browser;

I'm not sending a PR for this since I'm not sure if this is the correct fix -- unsure why this has broken in the first place, or whether it's never worked correctly in the first place.