기본 구조
function propertyDecorator(target: any, propName: string) {...}
function propertyDecoratorFactory(...) {
return function(target: any, propName: string) {...}
}
target, propName
Property Decorator Example1
2woongjae/ts-basic-decorators
function propertyDecorator(target: any, propName: string): any {
console.log(target);
console.log(propName);
return {
writable: false
};
}
class Test6 {
@propertyDecorator
name: string = 'Mark';
}
const test6 = new Test6();
test6.name = 'Anna'; // runtime error