microsoft / microsoft/TypeScript
JSDoc missing syntax for `new Map<string, string>()`
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms: JSDoc Map generics assignment any unsafe
Code
class MyServer {
constructor () {
// new Map is Map<any, any>; cannot call Map constructor with new Map<string, string[]>
/** @type {Map<string, string[]>} */
this.functions = new Map()
}
}
const myServer = new MyServer()
myServer.functions.get('foo')
Expected behavior:
Expected to be able to say what the Map contains when creating a new map. In typescript you can do new Map<string, string[]>() but theres no explicit generic parameter function invocation syntax for JSDoc
Actual behavior:
The type Map<any, any> exists. This fails the eslint rule of no-unsafe-assignment and this fails the no-any rule of tslint etc.
Note that doing something similar for arrays works because there's a special case inference for [] and it also works for Set because the constructor is defined differently and it has generic inference in the initialization statement.
Related Issues: Yes, in eslint https://github.com/typescript-eslint/typescript-eslint/issues/2109
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground の JavaScript 例を再現し、現在の Map<any, any> の結果と期待される型付き代入を比較します。JSDoc 型がジェネリックコンストラクター呼び出しをどのように表現するかを、関連する typescript-eslint issue をコンテキストとして確認します。サポートされる構文が定義され、例が安全でない any 型を推論しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100