【发布时间】:2017-12-06 02:13:10
【问题描述】:
import { Component} from "react";
export class Test extends Component<{}, {}> {
render() {
return "Hello";
}
}
function myFunction<P, S, C extends Component<P, S>>(c: C): void {
console.log("ctor", c);
}
const s = myFunction(Test);
错误:
“typeof Test”类型的参数不能分配给类型参数 '组件'。类型“typeof”中缺少属性“setState” 测试'。 07:35:53 - 编译完成。监视文件更改。
我是否需要使用 super.(..) 实现原始 react Component 类的所有成员?
【问题讨论】: