microsoft / microsoft/TypeScript
Erronous documentation for property decorators?
Abierto
@rbuckton ya está trabajando en esto.
Desde el 4/1/2017.
Docs
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
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?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.