microsoft / microsoft/TypeScript
Completion should suggest enum keys on some conditions
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
🔍 Search Terms
"enum", "enum keys", "completion"
✅ Viability Checklist
- 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, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Suggest enum keys completions without having to spell out the enum identifier.
For example, input CRE should be offered completion State.CREATED.
This completion can be limited to places where the enum type is expected, like a function argument or an object literal.
📃 Motivating Example
enum State {
CREATED,
CLOSED,
}
function f(v : State) {}
f(CRE ) // Expect completion on CRE
💻 Use Cases
- What do you want to use this for? better DX
- What shortcomings exist with current approaches? Have to first write the enum before enum key completions are offered.
- What workarounds are you using in the meantime? no
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 nombra ningún archivo, prueba ni punto de entrada. Empieza reproduciendo el ejemplo de completado de enum en el TypeScript language service y sigue cómo se filtran los completados en contextos donde se espera un tipo. Se considera terminado cuando un prefijo como CRE ofrece State.CREATED sin requerir primero el identificador del enum, preservando al mismo tiempo la salida y el comportamiento existentes de JavaScript.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- developer-experience, tooling
- 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
- 35/100