microsoft / microsoft/TypeScript

Display files with errors summary in `--watch` mode

オープン
#63,121 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

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

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 🔍 Search Terms

file listing watch mode
file summary watch mode

### ✅ Viability Checklist

- [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x] This wouldn't change the runtime behavior of existing JavaScript code
- [x] This could be implemented without emitting different JS based on the types of the expressions
- [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- [x] This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- [x] This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals

### ⭐ Suggestion

When running `tsc` with the `--watch` flag, we should see a list of files with errors, similar to what you see when running without `--watch`.

**Running without watch**

```
npx tsc
src/bar.ts:3:5 - error TS2554: Expected 0 arguments, but got 1.

3 bar(1);
~

src/foo.ts:2:3 - error TS18048: 'a' is possibly 'undefined'.

2 a.toString();
~

👇
Found 2 errors in 2 files.

Errors Files
1 src/bar.ts:3 👈 these are clickable and I don't have to scroll up the terminal to see them
1 src/foo.ts:2

👆
```

**Running with watch mode**

First run:
```
[9:49:05 AM] Starting compilation in watch mode...

src/bar.ts:3:5 - error TS2554: Expected 0 arguments, but got 1.

3 bar(1);
~

src/foo.ts:2:3 - error TS18048: 'a' is possibly 'undefined'.

2 a.toString();
~

[9:49:05 AM] Found 2 errors. Watching for file changes.
```

After a file change to bar.ts

```[9:49:53 AM] File change detected. Starting incremental compilation...

src/bar.ts:5:5 - error TS2554: Expected 0 arguments, but got 1.

5 bar(2);
~

src/foo.ts:2:3 - error TS18048: 'a' is possibly 'undefined'.

2 a.toString();
~

[9:49:53 AM] Found 2 errors. Watching for file changes.

```

**The ask**

Either by default, or with an option (`--showFileSummaryInWatchMode` ?) show the file summary when running with watch mode.

### 📃 Motivating Example

When running the TypeScript compiler in watch mode, you now have the option to see the list of files with errors.

### 💻 Use Cases

The main use case I have in mind, is for when I make a breaking change to a type in my codebase, and I need to know the impact this change can have.

Because these file paths are clickable in most IDEs (On MacOS cmd+click will open the file in the IDE), this file list can be a very convenient starting point to see the impact/make changes.

eg. I make a change to type X making a property optional, and I can see that this causes type errors in files A, B, C. I got to file A and to fix the type error, I make a return property there optional. I now see additional errors in files H,I,J,K,L,M,N,O. I abandon this approach.

### Related

https://github.com/Microsoft/TypeScript/issues/22124 - This is about pretty mode and watch mode. It's essentially asking the same thing 'I don't need to see all the details of the errors, I just want to see the file count'.

The issue is marked as completed - but I can't see that it actually does what the OP wants. AFAICT all it does is add colors to the terminal.

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

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

はじめの一歩

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

調査の方向性

tsc --watch のエントリポイントから開始し、その診断出力を通常の tsc の実行結果と比較します。issue の例を再現し、そのうえでファイルの概要をデフォルトの動作にするべきか、オプションにするべきかを判断します。各コンパイル後に、エラーを含むファイルのクリック可能な概要が watch モードに表示されれば完了です。

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

評価

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

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

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