class BeeKeeper {
hasMask: boolean;
}
class ZooKeeper {
nametag: string;
}
class Animal {
numLegs: number;
}
class Bee extends Animal {
keeper: BeeKeeper;
}
class Lion extends Animal {
keeper: ZooKeeper;
}
function createInstance<A extends Animal>(c: new () => A): A {
return new c();
}
var ss = createInstance(Lion).keeper.nametag; // typechecks!
var ss1 = createInstance(Bee).keeper.hasMask; // typechecks!
console.log(ss, ss1)
其实是读不到那个属性的。。。。那个属性是类的静态属性