microsoft / microsoft/TypeScript

Extract types from definition file

Abierto
#39,841 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Awaiting More Feedback Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza comparando lib.dom.d.ts y lib.webworker.d.ts; después, revisa la lista de API de TVMLJS referenciada. Define cómo deben exponerse las definiciones seleccionadas y sus dependencias sin copiar lib.dom.d.ts; se considera terminado cuando se admitan tanto el caso de uso de las definiciones superpuestas como un subconjunto específico de TVML.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.