Skip to content

Split the "lib.dom.d.ts" definition file apart #39255

Open
@JasonHK

Description

@JasonHK

Search Terms

lib.dom.d.ts, split, modular

Suggestion

I'm currently writing a TypeScript definition file for the API of a game, which will be submitted to DefinitelyTyped soon.

The API of the game exposes a Notification class to the global scope, which collides with the one in "lib.dom.d.ts" definition file. Not only that, but it also uses jQuery and XMLHttpRequest, forcing me to include that definition file.

Use Cases

By splitting the "lib.dom.d.ts" definition file apart, user can select only the APIs they need.

This change should not break the backward compatibility of old projects, although old versions of TypeScript will not support projects using the modular definition file.

Examples

For example, the "lib.dom.d.ts" definition file could be split up like this:

lib.dom.d.ts
|-- lib.dom.elements.d.ts
|-- lib.dom.notification.d.ts
|-- lib.dom.xhr.d.ts
`-- ... (other modules)

When some parts of the user's definition file collide with the "lib.dom.d.ts" definition file, the user can use the following instead:

{
    "compilerOptions": {
        "lib": [
            "DOM.Elements",
            "DOM.XHR",
            ... // (other modules except for "DOM.Notification")
        ]
        ...
    }
    ...
}

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions