microsoft / microsoft/TypeScript

Erronous documentation for property decorators?

オープン
#13,262 コメント 7 件 リアクション 0 件 担当者 1 名 GitHub で見る

@rbuckton がすでに取り組んでいます。

2017年1月4日 から。

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

説明

At https://www.typescriptlang.org/docs/handbook/decorators.html

..it reads under "Property Decorators"

If the property decorator returns a value, it will be used as the Property Descriptor for the member.

NOTE  The return value is ignored if your script target is less than ES5.

I'm running a simple example with target ES6

function MyPropDesc() {
  return function (targetProto: Object, propName: string | symbol)   {
    return {
      get: function() { console.log('in getter') }
    }
  }
}

class SomeClass {
  @MyPropDesc()
  someMember;
}

However, this doesn't seem to work. Also, when debugging this, my property decorator is being called from Reflect.js's DecoratePropertyWithoutDescriptor which ignores the result from the descriptor. And...typescript requires the decorator to return void or any. Documentation mistake?

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

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

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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