【发布时间】:2018-04-06 17:16:18
【问题描述】:
TS2415:“MyComponent”类错误地扩展了基类
我创建了以下代码sn-p:
import * as React from "react";
export interface IMyProps {
}
export interface IMyState {
}
export class MyComponent extends React.Component<IMyProps, IMyState> {
constructor(props: IMyProps) {
super(props);
}
render() {
}
}
但是 TypeScript 编译器给了我以下错误:
(9,14):错误 TS2415:“MyComponent”类错误地扩展了基础 类“组件”。属性“渲染”的类型 不兼容。 类型 '() => void' 不可分配给类型 '() => false |元素'。 类型 'void' 不可分配给类型 'false |元素'。
这里有什么问题?
【问题讨论】:
标签: reactjs typescript