TypeScript Version: 2.1.1
Code
function dec(): Function
{
return function (target: any, propKey: string, descr: PropertyDescriptor): void
{
console.log(target[propKey]);
//logs undefined
//propKey has three underscores as prefix, but the method has only two underscores
};
}
class A
{
@dec()
private __foo(bar: string): void
{
// do something with bar
}
}
Expected behavior:
target[propKey] should point to the decorated method
Actual behavior:
target[propKey] is undefined
My workaround is checking the property key in the decorator and deleting the first one underscore at the moment.
As far as I can tell the problem exists since typescript 2.1
Edit: updated code to reproduce problem when compiling
TypeScript Version: 2.1.1
Code
Expected behavior:
target[propKey]should point to the decorated methodActual behavior:
target[propKey]is undefinedMy workaround is checking the property key in the decorator and deleting the first one underscore at the moment.
As far as I can tell the problem exists since typescript 2.1
Edit: updated code to reproduce problem when compiling