I have this in my Landing.tsx:
<Pless handleClose={this.hidePless} showPless={this.state.showPlessPrompt} />
hidePless = () => {
this.setState({ showPlessPrompt: false });
};
In my Pless.tsx I have:
interface Props {
handleClose: any;
showPless: boolean;
}
export class Pless extends React.Component<Props> {
constructor(props: Props) {
super(props);
}
...
}
When I run my application I get this:
Failed to compile. C:/Users/.../Paperless.tsx (6,18): Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type.
Most likely a silly question but what should the type be?
CodePudding user response:
It is a void function as you are not returning anything from it, just doing something inside of it.
interface Props {
handleClose: () => void;
showPless: boolean;
}
Should keep the typescript compiler happy.
