-
Notifications
You must be signed in to change notification settings - Fork 421
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
Importing types from @types/web package #1207
Comments
I could imagine this as another potential export from this repo, its use case is pretty niche though IMO because you don't want to be including this in an environment which has I think it's very likely that TS could never move away from vending the interfaces globally because of ecosystem breakage, which means you'd have to be quite delicate in how a project using this would be set up |
Certainly need to think what would happen when some library exposes some type from modular @types/web@0.0.99 and the global enviroment has @types/web@0.0.100. But I think that's what already happening from DefinitelyTyped. 🤔 |
I mean, at least any mechanisms for pinning a package to a version exist -- it wouldn't be crazy to ship |
Maybe this isn't as important as I thought, because I'm not sure Node's "DOM compatible" APIs actually are 100% compatible. More at DefinitelyTyped/DefinitelyTyped#59905... |
I just updated the issue I linked a few months ago. It looks like as of Node v18, they're putting their "web compatible" types (or at least |
Per my update on the linked issue, I'm increasingly worried that Node is going to keep adding "compatible" interfaces in the global namespace, which actually wind up having some Node-exclusive properties or methods if you drill down far enough. Assuming this is the case, it would be great if someone on the TS team could take an interest in improving Node typings. At the moment, they're on a tightrope, constantly trying to be as accurate as possible without becoming fundamentally incompatible with lib-dom. It's only going to get harder. |
This can help us to unblock DefinitelyTyped/DefinitelyTyped#60924 without needing to duplicate types or re-invent the wheel... |
This has another purpose when working with Deno - there's no decent way to build an isomorphic project with multiple platform globals checked for at runtime. We went with fetching lib.dom.d.ts and scripting it to become importable.
I hope this can add motivation towards modular |
It wouldn't need to export anything to help with |
@felixfbecker This solves a very specific issue for fetch, while you can solve a very generic issue with this proposal. |
We also came across this use case for a React Native application where we only want to break out of RN in a very tiny corner of the repository (for a couple of functions), and as a result do not want to add We are using a cut down version of @MKRhere's Since this can be scripted, perhaps a standalone types library could be published as a side-effect of any updates to the DOM library for niche uses like ours. |
The
@types/web
package typings are published as alib
-- they don't declare any module, they don't import or export anything. You can include them using a triple-slash comment, but I don't think it's possible to import individual types. It would be helpful to be able to writeimport type {Element} from "web";
without having to pollute the whole global namespace with every web type.The text was updated successfully, but these errors were encountered: