microsoft / microsoft/TypeScript
Property decorator documentation is inaccurate?
Open
Nobody has claimed this yet.
Docs
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
From the official docs about property decorators:
"The return value is ignored too."
But the following example returns a new descriptor, and it works fine:
class Greeter {
@logProperty
greeting;
}
function logProperty(target, key): any {
var value;
var getter = function() {
console.log('getter');
return value;
};
var setter = function(newVal) {
value = newVal;
};
return {
get: getter,
set: setter,
enumerable: true,
configurable: true
};
}
const g = new Greeter();
const b = g.greeting;
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.
Research direction
Start with the Property Decorators section of the official TypeScript decorators documentation linked in the issue, then verify the shown property-decorator example and its returned descriptor behavior. Update the documentation so the statement about ignored return values accurately matches the documented example and observed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100