Closed green1052 closed 2 years ago
Thanks for taking the time for a PR, but I don't think this is correct. Browser is a namespace containing an interface named Browser. So you'd want the interface by specifying Browser.Browser
.
Browser.Browser
reads a bit confusing, I agree, but still the readme is correct here.. Feel free to argue against this with something I can reproduce.
Nevermind, I see the problem now. There is another issue with the sample code though: Circular definition of import alias 'Browser'
on line 1.
What seems to work for both cases on my end is this:
import type Browser from "webextension-polyfill";
declare global {
const browser: Browser.Browser;
}
Can you verify this works for you as well?
The types export both a Browser namespace as default and a Browser interface as a named export:
https://user-images.githubusercontent.com/1402241/158057495-286790b3-409e-48d2-bd0c-78c3f7d67ebd.mov
Your intent was probably import type Browser
but wrote import type { Browser
.
Either way works:
import type Browser from "webextension-polyfill";
declare global {
const browser: Browser.Browser;
}
import type { Browser } from "webextension-polyfill";
declare global {
const browser: Browser;
}
Given that the latter is shorter, that's what I prefer
This is what I get when I try your approach:
Not sure if it has to do with me using that in a project not properly set up for ES6 module loader.
That's likely because you're adding that file to this project 😅
No, I added it to https://github.com/Lusito/dict.cc-translation
Browser.Browser is invalid