我在class
中有TypeScript
继承问题。我的子class
不会不继承其parent
类的方法定义。
class Animal<T = any> {
public say(a: T) {
console.log(a);
}
walk(s: number) {
}
}
class Dog extends Animal<string> {
// a2 has a type of `any` instead of `string`
say(a2) {
}
// s2 recognized as `any`, which should be `number` from parent class definition
walk(s2) {
}
}