I am having hard time understanding this code:
function Console(target) {
console.log('Our decorated class', target);
}
@Console
class ExampleClass {
constructor() {
console.log('Yo!');
}
}
I got output as Our decorated class [Function: ExampleClass] after compiling and running using node why is it that i didnt get Yo!.Can you explain to me this code, I saved it as
decorators.ts
compiled using tsc --target ES5 --experimentalDecorators decorators.ts and then ran node decorators.js
documentation is too tough to understand
I am totally confused in angular we dont need to instantiate a class and everything works fine but here we have to.can you please tell me why we dont need to instantiate a class in typescript
new Console()somewhere to getYo!