microsoft / microsoft/TypeScript
Split the "lib.dom.d.ts" definition file apart
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando il file di definizione lib.dom.d.ts esistente e il modo in cui compilerOptions.lib seleziona le definizioni delle librerie. Definisci una suddivisione modulare che consenta agli utenti di omettere API in conflitto come DOM.Notification, preservando al contempo il comportamento attuale di lib.dom.d.ts per i progetti esistenti. Il lavoro è completato quando l’organizzazione proposta supporta API DOM selezionabili senza compromettere la compatibilità con le versioni precedenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100