virtualstate / navigation

Native JavaScript navigation [web api] implementation
MIT License
77 stars 5 forks source link

Global declaration via polyfill #34

Closed TomokiMiyauci closed 1 month ago

TomokiMiyauci commented 1 month ago

🚀 Feature Proposal

Provide a global declaration of the Navigation API.

Motivation

When using polyfill, we expect the type declaration to be extended as well.

Example

For example, urlpattern-polyfill includes a global declaration at the entry point.

fabiancook commented 1 month ago

Ideally the definitely types version would be utilised

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/dom-navigation/index.d.ts

Any differences from it in this implementation should be filed as a bug. I did go to define it as linked cause it made sense, but it would be preferred if @types/dom-navigation was used.

The navigation instance isn't set globally in node, only in a browser, as it expects a window to attach to.

In node it would be expected to use it as a referenced variable, or to first create a window to bind to.

TomokiMiyauci commented 1 month ago

Any differences from it in this implementation should be filed as a bug. I did go to define it as linked cause it made sense, but it would be preferred if @types/dom-navigation was used.

Thanks for letting me know.

I understood that the type definition is out of scope for this project. The issue is solved and I will close it.