为什么重写抽象方法参数类型在typescript中是any?
例如:为什么重写抽象方法参数类型在typescript中是any?,typescript,Typescript,例如: abstract class Base { abstract method(type: string): void } class Child extends Base { method(type) { console.log(type) } } 错误: 为什么覆盖方法参数是任意的?我在抽象类中定义了参数类型,为什么不使用它呢 我在抽象类中定义了参数类型,为什么不使用它呢 因为它没有在编译器中实现 TypeScript不会推断继承/实现的类型
abstract class Base {
abstract method(type: string): void
}
class Child extends Base {
method(type) {
console.log(type)
}
}
错误:
为什么覆盖方法参数是任意的?我在抽象类中定义了参数类型,为什么不使用它呢
我在抽象类中定义了参数类型,为什么不使用它呢
因为它没有在编译器中实现 TypeScript不会推断继承/实现的类型 为什么? 因为它打破了现实世界的密码。它想让你直言不讳