microsoft / microsoft/TypeScript

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

Offen
#39,255 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs Proposal Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Untersuchung der vorhandenen lib.dom.d.ts-Definitionsdatei und wie compilerOptions.lib Bibliotheksdefinitionen auswählt. Definiere eine modulare Aufteilung, die es Benutzern ermöglicht, in Konflikt stehende APIs wie DOM.Notification wegzulassen, während das aktuelle Verhalten von lib.dom.d.ts für bestehende Projekte erhalten bleibt. Als erledigt gilt dies, wenn die vorgeschlagene Organisation selektive DOM-APIs unterstützt, ohne die Abwärtskompatibilität zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.