microsoft / microsoft/TypeScript
Make ParameterDecorator and the like generic
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
lib Update Request
Missing / Incorrect Definition
ParameterDecorator is currently not generic, it can be attachted to any parameter. However, when a decorator is used for e.g. Dependency Injection purposes, some decorators require the type of the parameter to be consistent with the type of the decorator
Sample Code
E.g. we want this to work
class MyController {
requestThings(@UserId() userId: number): Thing[] { return [] }
}
But this to fail:
class MyController {
requestThings(@UserId() userId: string): Thing[] { return [] }
}
(as userId will be a number, not a string so the injection should ideally not be possible (at compile time)
Currently UserId is done more or less this way:
const UserId = (): ParameterDecorator => (target, key, index) => {
// do stuff
}
while I'd like to add number to ParameterDecorator:
const UserId = (): ParameterDecorator<number> => (target, key, index) => {
// do stuff
}
and I'd like typescript to check this when applying a decorator.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、ParameterDecorator の定義と、パラメーターデコレーターの適用に関するコンパイラーのチェックを見つけます。Issue の number と string の例を現在の動作と比較し、そのうえで、ジェネリックなパラメーター型をどのように表現し、検証すべきかを判断します。妥当なデコレーターの適用が受け入れられ、型が一致しないパラメーター型が適切なテストによって拒否されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100