我想将jsx重写为tsx。我有一个代码,从react-bootstrap方法重写方法:
import {Panel} from 'react-bootstrap';
class CustomPanel extends Panel {
constructor(props, context) {
super(props, context);
}
handleClickTitle = () => {
return;
}
}
打字稿编译器抛出异常
Base constructors must all have the same return type
如何解决?打字稿版本2.3.4
答案 0 :(得分:1)
反应引导继承的肮脏黑客
const UntypedPanel = Panel as any;
class CustomPanel extends UntypedPanel {
handleClickTitle = () => {
return;
}
}
const TypedCustomPanel = CustomPanel as any as React.ClassicComponentClass<PanelProps>;