microsoft / microsoft/TypeScript
Extract types from definition file
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
extract d.ts definition types
Suggestion
For a tvOS project I'm working with TVML and TypeScript. The JavaScript environment has some of the functionality of the browser, but not all classes are available (like FormData and URL).
You can see the classes that are supported here:
https://developer.apple.com/documentation/tvmljs
What I would like to do is to import a subset of type definitions from lib.dom.d.ts and then export them as lib.tvml.d.ts
Unfortunately I can't simply create a d.ts file and write this:
export { XMLHttpRequest } from "typescript/lib/lib.dom"
My next thought was to create a copy of lib.dom.d.ts and to remove everything except for the classes supported by TVML. However some of the types (like Document) are huge and they depend on other types which makes it even more complicated.
Another downside of a copy would be that it would miss out on the improvements that will be made over time to lib.dom.d.ts.
Use Cases
The file lib.webworker.d.ts has some overlap with lib.dom.d.ts (things like XMLHttpRequest). If we could create a d.ts by importing definitions from another d.ts it could simplify the built-in library definitions.
It also offers developers an easy way to pick which definitions are allowed to be used in the project.
Examples
See example under Suggestion section.
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 confrontando lib.dom.d.ts e lib.webworker.d.ts, quindi esamina l’elenco dell’API TVMLJS indicato. Definisci come devono essere esposte le definizioni selezionate e le relative dipendenze senza copiare lib.dom.d.ts; il lavoro è completato quando sono supportati sia il caso d’uso delle definizioni sovrapposte sia un sottoinsieme specifico di TVML.
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
- 30/100