【发布时间】:2018-01-18 04:36:44
【问题描述】:
我想将 jsx 重写为 tsx。我有一个从 react-bootstrap 方法重写方法的代码:
import {Panel} from 'react-bootstrap';
class CustomPanel extends Panel {
constructor(props, context) {
super(props, context);
}
handleClickTitle = () => {
return;
}
}
Typescript 编译器抛出异常
Base constructors must all have the same return type
如何解决?打字稿版本 2.3.4
【问题讨论】:
-
什么会解决你的问题(但不是首先导致它)是完全省略构造函数。只调用
super()的构造函数是多余的。 -
如果删除构造函数我有相同的类型加密错误 MyFile.tsx(2, 27): error TS2510: Base constructor must have the same return type
标签: reactjs typescript ecmascript-6 react-bootstrap