microsoft / microsoft/TypeScript
Smart indentation on separated elements should reuse the prior element's starting base indentation
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Aucun fichier d’implémentation ni test n’est indiqué. Commencez par localiser le point d’entrée de l’indentation intelligente de TypeScript et comparez son comportement à celui des exemples d’unions séparées, de variables multilignes, d’objets et de classes ; examinez la relation avec #52899. Le travail est considéré comme terminé lorsque les exemples utilisent l’indentation de base initiale de l’élément précédent, y compris les cas d’ASI indiqués, avec une couverture de régression.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100