microsoft / microsoft/TypeScript
Erronous documentation for property decorators?
Đang mở
@rbuckton đang làm issue này rồi.
Từ ngày 4/1/2017.
Docs
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
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?
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Đánh giá
Issue này chưa được đánh giá.