microsoft / microsoft/TypeScript
Support Closure Compiler-style @typedef
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
Search Terms
- Closure Compiler typedef
Suggestion
With Closure Compiler-style JSDoc, you name an @typedef type definition by introducing a var in the next statement:
/** @typedef {(string|number)} */
var NumberLike;
TypeScript doesn't recognize this construct. Instead, it wants you to write:
/** @typedef {(string|number)} NumberLike */
Use Cases
Migrating code written for use with Google's Closure Compiler over to TypeScript.
Examples
See above. My proposal is that, when prefixed with an @typedef with only a type (and no name), a variable definition would create a symbol in the type namespace in addition to the value namespace.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
→ If the variable has the same name as an existing type, this would create a break. But this would indicate an issue if the two types disagreed. - 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
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
No se nombran archivos de implementación, pruebas ni puntos de entrada. Empieza rastreando cómo TypeScript gestiona las declaraciones JSDoc con @typedef al estilo de Closure y, después, compara la forma con nombre existente con la forma basada en variables propuesta; se considera terminado cuando el ejemplo crea el símbolo de tipo solicitado sin cambiar el JavaScript emitido.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, typescript
- Área
- compilers
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 35/100