Feature request: split whatwg definitions in separate files

Open
#1,685 0 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
tooling

Research direction

No files, tests, or entry points are identified in the issue. Start by reading related issues 41727 and 31535, then inspect how this generator organizes DOM library definitions. Done means users can select separate whatwg URL and fetch definitions alongside an ECMAScript lib without relying on the broader DOM lib.

Written by the indexing model from the issue text.

Description

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
Dominant language
TypeScript
Stars
740
Forks
474
Avg merge
2d 8h
Merged PRs (30d)
15

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/TypeScript-DOM-lib-generator

All issues in microsoft/TypeScript-DOM-lib-generator

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.