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

Providing types with the package by default #651

Closed
Lusito opened this issue Jul 21, 2024 · 2 comments
Closed

Providing types with the package by default #651

Lusito opened this issue Jul 21, 2024 · 2 comments

Comments

@Lusito
Copy link
Contributor

Lusito commented Jul 21, 2024

Hey, I'm the author of the type generator for @types/webextension-polyfill .

There is no other maintainer for @types/webextension-polyfill aside from me and therefore it can be hard to find a reviewer on DefinitelyTyped pull-requests that understands the issues at hand. The latest PR has been in review hell, with reviewers requesting changes and then ignoring the PR after I've replied. After almost 2 months I've just closed the PR and recreated it in the hope, that this time will be better.

Any chance we could ship the types with the package itself instead of using DefinitelyTyped?
Maybe even move the generator project to this repository?

@Rob--W
Copy link
Member

Rob--W commented Aug 1, 2024

We are not interested in including the types in this repo. As you can see from the update frequency of the polyfill, it is updated infrequently. We also anticipate that the polyfill will become obsolete relatively soon (see below for details). Even past the end of the polyfill's support schedule, the types can still continue to be useful (as a generic "webextension API" type definition).

The polyfill's primary purpose is to offer extension APIs through a Promise-based API, under the browser namespace.

Firefox and Safari have first-class support for the browser namespace.

Chrome does not support Promise at all in Manifest Version 2, but they have deprecated MV2 and its support may disappear in June 2025 - https://developer.chrome.com/docs/extensions/develop/migrate/mv2-deprecation-timeline

Chrome's Manifest Version 3 supports Promises, under the chrome namespace. It does not support Promise as a return value in runtime.onMessage, but they have expressed support for that at https://crbug.com/1185241 .

Because Chrome already offers a Promise-based API under the chrome namespace (in MV3), a polyfill for that could be as simple as

globalThis.browser ??= chrome;

There are also plans to bring the browser namespace to Chrome, following discussion in the WECG. At that point this polyfill would become a no-op, because it does not modify anything if the browser global already exists.

@Rob--W Rob--W closed this as completed Aug 1, 2024
@Lusito
Copy link
Contributor Author

Lusito commented Aug 13, 2024

Thanks for the detailed explanation.

Providing types without having a package for it wouldn't work with DefinitelyTyped though, so I guess I'll convert my project back to a polyfill project which exports only a single constant. That would also resolve the hassles of getting code-reviews through on DT.

Though as can be seen in Lusito/webextension-polyfill-ts#105, there still seem to be incompatible differences between chrome and firefox aside from the promise based API.

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