microsoft / microsoft/TypeScript
Smart indentation on separated elements should reuse the prior element's starting base indentation
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es werden keine Implementierungsdateien oder Tests genannt. Beginne damit, den Einstiegspunkt für die intelligente Einrückung von TypeScript zu finden, und vergleiche sein Verhalten mit den Beispielen für getrennte Unions, mehrzeilige Variablen, Objekte und Klassen; prüfe den Zusammenhang mit #52899. Als erledigt gilt die Aufgabe, wenn die Beispiele die anfängliche Basiseinrückung des vorherigen Elements verwenden, einschließlich der genannten ASI-Fälle, und eine Regressionstestabdeckung vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100