【发布时间】:2021-06-20 17:48:03
【问题描述】:
在使用 React 和 TypeScript 时,我的联系人组件中出现 ESlint 错误 Don't use `{}` as a type. `{}` actually means "any non-nullish value".。
组件没有任何道具。
export default class Contact extends React.Component<{}, MyState> {
constructor(props = {}) {
super(props);
this.state = {
signedUp: false,
};
}
}
我尝试改用 null,但这会引发其他 ESLint 错误。
【问题讨论】:
-
unknown会这样做吗?或者甚至可能是never -
我从来没有尝试过,但未知的创建了它自己的问题。
标签: reactjs typescript eslint lint