reactjs - 扩展 React.Component 警告

标签 reactjs typescript

当我像这样扩展 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/

相关文章:

javascript - React 中的 ParticlesJS 组件隐藏了媒体查询但不会返回显示

javascript - 无法访问对象值

javascript - 如何使用 webpack 将全局 JS 文件包含到我的 React 项目中?

reactjs - 在React组件Props中使用通用流类型并实例化通用组件>

javascript - angular中如何通过@Input和@Output获取Id

typescript - Typescript 编译器选项 --libs 中的 es6 和 es2015 有什么区别

typescript - 为什么无法通过 getter [typescript] 获取父类(super class)的属性

reactjs - mapDispatchToProps 上的 Redux Thunk Typescript 错误

reactjs - window.location.href 与 react-router-dom 的重定向实用程序

typescript - Firebase.js 7.x 是否破坏了与 Typescript 2.6.x 的兼容性?