Why don't get an error after typing a function that should return nothing and then access props.onClick inside Message component that returns something value?
type MessageProps = {
onClick: () => void,
value?: string
}
const Message: React.FunctionComponent<MessageProps> = (props: any) => {
return (
<>
<h1>Example message</h1>
<button onClick={props.onClick}>click</button>
</>
)
}
const App = (props: any) => {
return (
<div className="App">
<Message onClick={() => 2} />
</div>
);
}
export default App;
onClickexpects a function, and you're giving it one