export class ConstructorExample { constructor(private a: number, private b: number, public c: number, protected d: string) { } execute() { this.a; this.b; this.c; this.d; //类静态部分与实例部分 //先定义静态部分的接口 interface ClockInterface { tick(); aaa(): void; } interface ClockConstructor { new(hour: number, minute: number): ClockInterface; show(): void; } let Clock: ClockConstructor; let clock = new Clock(1, 1); Clock.show(); //----------------------------接口与类的区别------------------------------// //1、什么时候用接口? //2、什么时候用类? //当很多时候我们需要毫无关系的对象集提供统一的属性或者方法调用,此用用接口更好,例如: interface WeightInfo { weight: number; } interface ColorInfo { color: number; } class Man implements WeightInfo { weight: number; } class Car implements WeightInfo, ColorInfo { weight: number; color: number; } class Wall implements ColorInfo { color: number; } function choose(object: WeightInfo | ColorInfo) { } } }