Nest: decorator apply to Injectable class can not get that object's properties

Created on 12 Jul 2018  路  3Comments  路  Source: nestjs/nest

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior


I write a Log decorator which can apply to a method
/**
log the method execute
/
export const Log = () => {
return (target, name, descriptor: PropertyDescriptor) => {
const { value: method } = descriptor
/

* just log
*/
descriptor.value = function(...args){
console.log('before method call')
const result = method.call(target, ...args)
console.log('after method call')
return result
}
}
}

but when i apply it to a Injectable class, i missing the properties of that object,but apply to the controller class is ok

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z


For Tooling issues:
- Node version: XX  
- Platform:  

Others:

question 馃檶

Most helpful comment

@kamilmysliwiec I have found the problem,it's my fault ,the target is not the class instance,it is the class prototype锛宻o i can not get the property of the class instance

All 3 comments

Please, provide a minimal reproduction of this issue.

@kamilmysliwiec I have found the problem,it's my fault ,the target is not the class instance,it is the class prototype锛宻o i can not get the property of the class instance

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artaommahe picture artaommahe  路  3Comments

cdiaz picture cdiaz  路  3Comments

KamGor picture KamGor  路  3Comments

menme95 picture menme95  路  3Comments

yanshuf0 picture yanshuf0  路  3Comments