我的Landing.tsx里有这个
<Pless handleClose={this.hidePless} showPless={this.state.showPlessPrompt} />
hidePless = () => {
this.setState({ showPlessPrompt: false });
};在我的Pless.tsx中有:
interface Props {
handleClose: any;
showPless: boolean;
}
export class Pless extends React.Component<Props> {
constructor(props: Props) {
super(props);
}
...
}当我运行我的应用程序时,我得到以下信息:
编译失败。C:/Users/./Paperless.tsx.tsx (6,18):“任何”丢失类型安全性的类型声明。考虑用更精确的类型来代替它。
很可能是个愚蠢的问题,但这种类型应该是什么呢?
发布于 2022-01-23 20:48:32
这是一个空函数,因为你没有从它返回任何东西,只是在里面做一些事情。
interface Props {
handleClose: () => void;
showPless: boolean;
}应该使类型记录编译器保持愉快。
https://stackoverflow.com/questions/70826404
复制相似问题