-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Domain: LS: Smart IndentationAutomatic indenting after a newline (not quite formatter/formatting)Automatic indenting after a newline (not quite formatter/formatting)RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
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.
Metadata
Metadata
Assignees
Labels
Domain: LS: Smart IndentationAutomatic indenting after a newline (not quite formatter/formatting)Automatic indenting after a newline (not quite formatter/formatting)RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneSuggestionAn idea for TypeScriptAn idea for TypeScript