microsoft / microsoft/TypeScript

Display signature help or completions for tuples with labels

Abierto
#53,197 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Experience Enhancement Help Wanted Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

Suggestion

🔍 Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

✅ Viability Checklist

My suggestion meets these guidelines:

  • [x This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [x This wouldn't change the runtime behavior of existing JavaScript code
  • [x This could be implemented without emitting different JS based on the types of the expressions
  • [x This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • [x This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

declare const coords: [x: number, y: number]

const [/**/] = coords

The problem: having no idea what a name to type as you don't know what the type of it.

I'm using it with my plugin and it looks very simple (and useful IMO):

Of course, you can hover of the variable to fiture it out, but what about the following example:

const a: {
    coords: [x: number, y: number] | string | { x: number; y: number }/* | even more types */
} = {
    coords: [/**/], // the type with x, y tuples can be even truncated, so you can only guess names of labels
}

I understand that labeled tuples introduced in ts4.0 were designed primarily for parameters usage, but I've seen them used for shorter static data declarations as well.

However, if you think that usage signature help is redundant and incorrect, what about having completions for tuple labels at least? There is already completions when acessing such symbols via dot property access. For example for first example it would be keyword completion with label x and [0]: number detail.

💻 Use Cases

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 revisando los ejemplos de labeled tuples y los dos comportamientos propuestos: signature help durante la desestructuración de tuplas y completions para tuple labels. Define qué comportamiento debería admitirse y cómo debería funcionar para unions o truncated tuple types; después, identifica los entry points y las pruebas relevantes de TypeScript language-service. Se considera terminado cuando la interacción elegida proporciona información útil sobre las labels sin cambiar la salida en runtime.

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

Evaluación

Stack tecnológico
typescript
Área
developer-experience
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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.