microsoft / TypeScript-DOM-lib-generator

Tool for generating dom related TypeScript and JavaScript library files
Apache License 2.0
616 stars 417 forks source link

Feature request: split whatwg definitions in separate files #1685

Open matthieusieben opened 8 months ago

matthieusieben commented 8 months ago

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:

Related issues