microsoft / microsoft/TypeScript
Smart indentation on separated elements should reuse the prior element's starting base indentation
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
Consider what I'd call some "ideal" smart indentation for the following code samples:
type Foo =
| "hello"
| "world";
{| "indentation": 0 |}
let x = 10,
y = 2;
{| "indentation": 0 |}
let x = 10,
y = 2,
{| "indentation": 4 |}
let obj = {
x: "hello" +
"world",
{| "indentation": 4 |}
}
class C {
x = "hello" +
"world";
{| "indentation": 4 |}
}
I've specified the "expected" indentation in each of these cases; however, TypeScript today keeps indentation are the same level as the prior line which is wrong. This is especially annoying for the multi-line union case.
There is some ambiguity when one uses an ASI-assuming style though. In these cases, I would personally err on the side of expecting the start indentation.
type Foo =
| "hello"
| "world"
{| "indentation": 0 |}
```ts
let x = 10,
y = 2
{| "indentation": 0 |}
class C {
x = "hello" +
"world"
{| "indentation": 4 |}
}
Then, even for cases where ASI doesn't really apply:
let obj = {
x: "hello" +
"world"
{| "indentation": 4 |}
}
I would say we should pick the start element's base (where x starts), since we'll start doing #52899 eventually.
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 ni pruebas. Empieza localizando el punto de entrada de la indentación inteligente de TypeScript y compara su comportamiento con los ejemplos de uniones separadas, variables multilínea, objetos y clases; revisa la relación con #52899. Se considera terminado cuando los ejemplos usan la indentación base inicial del elemento anterior, incluidos los casos de ASI indicados, con cobertura de regresión.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100