function writable(canBeWritable:boolean){
return function(target:any, propName:string):any{
console.log(target);
console.log(propName);
return{
writable:canBeWritable,
};
}
}
class Person{
@writable(false)
name:string = 'kim';
constructor(){
console.log('new Person()');
}
}
const p= new Person();
console.log(p.name);
'Developer' 카테고리의 다른 글
[typescript]타입가드 (0) | 2020.10.02 |
---|---|
[typescript]Decorator - 파라미터에 decorator 붙혀서 통제하기 (0) | 2020.10.02 |
[typescript]Decorator - 메소드에 decorator 붙혀서 통제하기 (0) | 2020.10.02 |
[typescript]Decorator - 기본 (0) | 2020.10.02 |
[typescript]Generic type 응용 (0) | 2020.10.02 |