microsoft / microsoft/TypeScript
Erronous documentation for property decorators?
Open
@rbuckton is already working on this.
Since Jan 4, 2017.
Docs
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.