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

Feature request: split whatwg definitions in separate files #1685

Open
matthieusieben opened this issue Feb 6, 2024 · 0 comments
Open

Feature request: split whatwg definitions in separate files #1685

matthieusieben opened this issue Feb 6, 2024 · 0 comments

Comments

@matthieusieben
Copy link

matthieusieben commented Feb 6, 2024

Use case

I want to write an isomorphic library that runs in the browser and nodejs. I want to make sure that I only rely on globals that are available in both environments. Currently, to do this, I must use lib: ["dom"] and types: ["node"], which results in defined globals that are not actually available in both runtime envs, leading to a fake sense of type safety when writing code.

Suggested solution

As a user of typescript, I would like to be able to pick more precisely the libs I depend on. For example: lib: ["es2022", "whatwg.url", "whatwg.fetch"]

There would be a lot of benefit to doing this:

  • @types/node would not have to re-define definitions already provided by typescript (new URL(u as URL) incorrectly yields an error when using types: ["node"])
  • All libraries targeting both dom & scripthost envs would benefit from improved type safety

Related issues

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

1 participant