microsoft / microsoft/TypeScript

Smart indentation on separated elements should reuse the prior element's starting base indentation

オープン
#53,548 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Domain: LS: Smart Indentation Rescheduled Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

実装ファイルやテストは指定されていません。まず TypeScript のスマートインデントのエントリポイントを特定し、分離されたユニオン、複数行の変数、オブジェクト、クラスの例に対する動作を比較してください。#52899 との関係も確認してください。完了条件は、指定された ASI のケースを含め、例が直前の要素の開始時の基準インデントを使用し、回帰テストのカバレッジがあることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。