[英]Why is my React / TypeScript app generating a compile error?
I've downloaded the following app (which works in the sandbox):我已经下载了以下应用程序(在沙箱中工作):
https://codesandbox.io/s/wbkd-react-flow-forked-78hxw4 https://codesandbox.io/s/wbkd-react-flow-forked-78hxw4
Locally, after I run:在本地,我运行后:
npm install
and then接着
npm start
I get the following error:我收到以下错误:
TypeScript error in /wbkd-react-flow-forked/src/components/ErrorBoundary.tsx(6,15):
Parameter 'props' implicitly has an 'any' type. TS7006
4 |
5 | export class ErrorBoundary extends Component {
> 6 | constructor(props) {
| ^
7 | super(props);
8 | this.state = { hasError: false };
9 | }
How do I resolve the compile error?如何解决编译错误?
Add typing to your props:为你的道具添加打字:
type ErrorBoundaryProps = {
someProps: boolean;
}
export class ErrorBoundary extends Component<ErrorBoundaryProps> {
constructor(props) {
super(props);
this.state = { hasError: false };
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.