microsoft / microsoft/TypeScript

class-factory mixins in type declaration files are impossible. (allow implicit return types in declaration files somehow)

Abierto
#35,715 2 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
2 d 4 h
PR fusionados (30 d)
132

Descripción

Search Terms

When the compiler is set to emit declaration files, class-factory mixins are no longer allowed. This is yet another issue that prevents class-factory mixins from being adopted in library code that need to be publish as JS with sibling declaration files.

Suggestion

Allow implicit return types to be somehow representable in declaration files.

Use Cases

Enables many use cases that are otherwise impossible when emitting declaration files. I believe declaration files should support all features of TS.

Examples

Write a mixin function, and try to emit declaration files.

Workaround

As a workaround I publish TypeScript source files in my NPM packages, then I point the types field in package.json to my source entry point. I don't publish declaration files because I can't build them.

Pointing to source files opens up other cans of worms, and prior to TS 3.6.3 I was not able to point to source files due to pre-existing bugs in tsc in that scenario. After TS 3.6.3, I can successfully publish source files and point types to sources containing class-factory mixins, but I'm afraid this is brittle and can break with an upgrade to TS (just as it was broken from some point prior to v3.6.3).

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

No se nombra ningún archivo fuente ni ninguna prueba. Empieza reproduciendo el ejemplo de class-factory mixin mientras emites declaration files y, después, rastrea el comportamiento de declaration-emission implicado. Se considera terminado cuando pueda emitirse una representación compatible del tipo de retorno implícito del mixin sin requerir el workaround de publicar archivos fuente de TypeScript.

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
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.