microsoft / microsoft/TypeScript
Extract types from definition file
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Vergleich von lib.dom.d.ts und lib.webworker.d.ts und prüfe anschließend die referenzierte TVMLJS API-Liste. Definiere, wie ausgewählte Definitionen und ihre Abhängigkeiten verfügbar gemacht werden sollen, ohne lib.dom.d.ts zu kopieren; abgeschlossen ist die Aufgabe, wenn sowohl der Use Case für sich überschneidende Definitionen als auch eine TVML-spezifische Teilmenge unterstützt werden.
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
- 30/100