kingBook

导航

TypeScript 扩展声明文件 .d.ts

如:扩展LayaAir的Vector3,加入一个say方法
LayaAirExtensions.d.ts

declare module Laya{
      interface Vector3 {
            say(msg:string):void;
      }
}
//或
/*declare module laya.d3.math{
      interface Vector3{
            say(msg:string):void;
      }
}*/
let v3=new Laya.Vector3();
v3.say("hello");//不报错

posted on 2021-02-01 12:14  kingBook  阅读(357)  评论(0编辑  收藏  举报