microsoft / microsoft/TypeScript

Extract types from definition file

Aperta
#39,841 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. 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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.