microsoft / microsoft/TypeScript

Provide a `this` type for `get`/`set` methods in `Reflect.defineProperty` options

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

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

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

説明

Code

var A: {a?: number, b: number} = {b:2}
Reflect.defineProperty(A, 'a', {
  // set(this: any, value: any) { // to fix
  set(value: any) {
    console.log(this.b); // Property 'b' does not exist on type 'PropertyDescriptor'.
  },
  enumerable: true,
  configurable: true
});
A.a = 1;
// expect the context of setter is A

Expected behavior:

expect the context of the setter is A

Actual behavior:

Property 'b' does not exist on type 'PropertyDescriptor'.

Playground Link:

https://www.typescriptlang.org/play/index.html?strictPropertyInitialization=false&alwaysStrict=false&experimentalDecorators=true&emitDecoratorMetadata=true#code/LAKAbghgTgBAggLhgbwgfiQOwK4FsBGAplADQz5Z5FQC+MAvChQEw2gBKhAZgDaEDGAFwB0AE24BLTIQAKUAPYAHYoICeACjhkA5BG1lkoGDADOhQesg9shJBEyqAlCiPGY-eZhPy+wnvIBzdUEACwkTYXxHAG4YAHo4mDklFVUYbXxtGFF5QhMYTHlBGEIAD3Dizxg1ZXTk5Sg1ABE8-igJRUF5KG1hVxoSV0IcXGIIfD4kQSgbQZBjD0wuCQDsKHHJ6pnCUBoY0DhhCAYYAEZo0ASS0uUhapDCd09BMsquU3MX2HD4IA

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

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

はじめの一歩

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

調査の方向性

リンク先の TypeScript Playground の例から始め、setter の推論された this と期待される receiver 型を比較します。Reflect.defineProperty のオプションと PropertyDescriptor の型定義を追跡し、その後、適切な既存のテスト領域にこの例のカバレッジを追加します。setter コンテキストが報告されたエラーなしで対象オブジェクトとして型付けされれば完了です。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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