microsoft / microsoft/TypeScript

Feature Request: Provide an option to configure the presentation of Arrays

Abierto
#44,715 1 comentario 9 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

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

Descripción

Suggestion

Provide an option to configure the presentation of Arrays.

🔍 Search Terms

This suggestion is hard to search for ☹️

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behaviour 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 feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

I would like to see an option that will allow for altering the presentation of Arrays.

📃 Motivating Example

When reading through type errors or hovering over source code in VS Code, I find it hard to easily distinguish between Arrays, Tuples, Arrays of Tuples, Tuples with Arrays in them etc.

I personally use linting rules so that I know that when I see a [ or ] in my source code, I am explicitly dealing with a Tuple.

For example, I find Array<[Array<T>]> far easier to quickly parse than [T[]][]. This may simply be attributed to my bias of writing code in the generic form. Though, this gets worse with increased levels of nesting.

🎨 Prior art

The tslint rule array-type can be used to enforce using the generic form of Array<T>. Secondarily, this rule was also ported as the @typescript/eslint rule array-type.

💻 Use Cases

I find hovering over my own code and seeing it presented differently a bit frustrating. Consider the following playground screenshot:

Hover

In addition toarray-types options of "array", "generic", "array-simple", a fourth option of "preserve" could be added which would address the screenshot above.

I would like to suggest the following option:

Flag Type Default value
--arrayType "array" | "generic" | "array-simple" | "preserve" "preserve"

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 con el playground de TypeScript enlazado y el ejemplo de hover de VS Code para comparar la presentación actual de arrays anidados y tuplas. Revisa los valores solicitados de --arrayType y define como completado que la sintaxis de los arrays se conserve o se formatee de manera coherente en los errores de tipo y las vistas hover, sin cambiar el JavaScript generado.

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
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.