gpt4 book ai didi

reactjs - 扩展 React.Component 警告

转载 作者:搜寻专家 更新时间:2023-10-30 21:01:02 25 4
gpt4 key购买 nike

当我像这样扩展 React.Component 时:

export default class App extends React.Component<any, any > {

constructor (props: React.ReactPropTypes) {
super(props);
}

// other code
}

我收到以下警告:

./src/App.tsx [37, 50]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence. [37, 55]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence.

解决这些警告的最佳方法是什么?

最佳答案

在你的 tslint.json 中你可以放:

{"rules": {
"no-any": false
}
}

关于reactjs - 扩展 React.Component 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47573424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com