microsoft / microsoft/TypeScript
Feature Request: Provide an option to configure the presentation of Arrays
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Suggestion
Provide an option to configure the presentation of Arrays.
🔍 Search Terms
This suggestion is hard to search for ☹️
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behaviour of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
I would like to see an option that will allow for altering the presentation of Arrays.
📃 Motivating Example
When reading through type errors or hovering over source code in VS Code, I find it hard to easily distinguish between Arrays, Tuples, Arrays of Tuples, Tuples with Arrays in them etc.
I personally use linting rules so that I know that when I see a [ or ] in my source code, I am explicitly dealing with a Tuple.
For example, I find Array<[Array<T>]> far easier to quickly parse than [T[]][]. This may simply be attributed to my bias of writing code in the generic form. Though, this gets worse with increased levels of nesting.
🎨 Prior art
The tslint rule array-type can be used to enforce using the generic form of Array<T>. Secondarily, this rule was also ported as the @typescript/eslint rule array-type.
💻 Use Cases
I find hovering over my own code and seeing it presented differently a bit frustrating. Consider the following playground screenshot:

In addition toarray-types options of "array", "generic", "array-simple", a fourth option of "preserve" could be added which would address the screenshot above.
I would like to suggest the following option:
| Flag | Type | Default value |
|---|---|---|
--arrayType |
"array" | "generic" | "array-simple" | "preserve" |
"preserve" |
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている TypeScript playground と VS Code のホバー例から始めて、ネストされた配列とタプルの現在の表示を比較します。要求された --arrayType の値を確認し、出力される JavaScript を変更せずに、型エラーとホバー表示で配列構文が一貫して保持またはフォーマットされることを完了の定義とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100