microsoft / microsoft/TypeScript
Feature Request: Display JSDoc Array of Objects as Array
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Hey guys,
I tried searching for a similar issue, but couldn't find one. If there is another, I'm happy to close this one. Essentially, when specifying that a particular entity is an array of objects with a definite shape, I would like it if those were displayed as an actual array. Given the following Javascript:
/**
* @param {Object} params
* @param {Object[]} params.items - Array of items
* @param {string} params.items[].name - Name of the item
* @param {string} params.items[].value - Value of the item
*/
function myFunc({ items = []}){
items.map(item => {
console.log(item.name, item.value)
})
}
Currently, on hover, VSCode displays the type hinting as:
function myFunc({ items }: {
items: {
name: string;
value: string;
};
}): void
However, this makes it appear that items is an object. That is incorrect because items is instead an array of objects, and is specified as such in the JSDoc. I would expect something akin to when you specify the properties inline:
JS:
/**
* @param {Object} params
* @param {{name: string, data: string}[]} params.items - Array of items
*/
function myFunc({ items = []}){
items.map(item => {
console.log(item.name, item.value)
})
}
Hover:
function myFunc({ items }: {
items: {
name: string;
data: string;
}[];
}): void
The problem with using the inline format is the lack of an explanation of individual properties, and some object shapes can get very long, and even be nested. Additionally, the above solution waits until the end of the object definition to denote that the property should be an array. It seems that it would be more user-friendly if it was denoted as an array at the beginning, like this:
function myFunc({ items }: {
items: [{
name: string;
data: string;
}];
}): void
Thanks for your time and the great product!!
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
実装ファイルもテストも指定されていません。VSCode で JSDoc の例を再現し、TypeScript language-service の hover 出力を調べたうえで、ドキュメント化された配列プロパティがどのように表現され、表示されるかを追跡します。完了条件は、ドキュメント化された Object[] プロパティがオブジェクトの配列として表示され、個々のプロパティの説明が保持されること、および例の動作をカバーすることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript, vscode
- 領域
- developer-experience, tooling
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100