tsc --init 目的是为了生成config.json 文件
在不修改类的前提下对方法属性的扩展
1-1类装饰器
function logClass(params:any){console.log(params);params.prototype.skill = "js"}@logClass//该位置Student报错:在config.json文件中找到 "experimentalDecorators": true,解除备注class Student{}// 类装饰器:在不修改类的前提下,对类拓展(添加属性,添加方法)var s:any = new Student ()console.log(s.skill)
