microsoft / microsoft/TypeScript
Smart indentation on separated elements should reuse the prior element's starting base indentation
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non sono indicati file di implementazione né test. Inizia individuando il punto di ingresso dell'indentazione intelligente di TypeScript e confronta il suo comportamento con gli esempi di union separate, variabili su più righe, oggetti e classi; esamina la relazione con #52899. Il lavoro è completo quando gli esempi usano l'indentazione di base iniziale dell'elemento precedente, inclusi i casi ASI indicati, con copertura di regressione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100