-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when adding decorator to class #12
Comments
@nrfribeiro have installed |
Hi, Now I have another question. |
@nrfribeiro I left in that thread a comment with the example. Would it work for you? |
Hi, I don't think so. |
@nrfribeiro the same principle applies import { LogClass as LogClassOriginal, IClassLoggerConfig } from 'class-logger'
let enabled: boolean = true
export const enable = () => { enabled = true }
export const disable = () => { enabled = false }
export const LogClass = (config: IClassLoggerConfig) => {
if (!enabled) {
return () => undefined // return an empty decorator placeholder
}
return LogClassOriginal(config)
} |
Hi, Thanks for your reply. |
@nrfribeiro got it. In this case, it's not possible to completely disable the proxy creation, but you can make it not log anything, import { setConfig } from 'class-logger'
setConfig({
log: () => {},
logError: () => {}
}) This way you'll still have a wrapping proxy and you'll pay a performance penalty for that. However, I expect 99% of the apps not even noticing the performance impact. |
Hi,
I'am having a error when executing my code after adding the decorator to a class.
! TypeError: Reflect.defineMetadata is not a function
at D:\Wiredkode\Projects\Covid19NeuroTracking\Functions\functions\node_modules\class-logger\dist\src\log-class.decorator.js:7:13
at __decorate (D:\Wiredkode\Projects\Covid19NeuroTracking\Functions\functions\lib\controlers\UsersController.js:5:95)
at Object. (D:\Wiredkode\Projects\Covid19NeuroTracking\Functions\functions\lib\controlers\UsersController.js:20:5)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object. (D:\Wiredkode\Projects\Covid19NeuroTracking\Functions\functions\lib\express\endpoints\post_sysadmins.js:5:27)
! We were unable to load your functions code. (see above)
The text was updated successfully, but these errors were encountered: