TS blows up with an error:
Error:(8, 20) TS7031: Binding element 'on' implicitly has an 'any' type.
Error:(8, 24) TS7031: Binding element 'children' implicitly has an 'any' type.
I have following function. I pass it two arguments.
//
function On({on, children}) {
return (
<div>{on} {children}</div>
)
}
How do I specify types for arguments in such a case? This syntax does not work:
function On({(on as boolean), (children as HTMLElement[])}) {
function On({(on: boolean), (children: HTMLElement[])}) {
function On({on: boolean, children: HTMLElement[]}) {
return (
<div>{on} {children}</div>
)
}
{ on, children }: {on: boolean, children: HTMLElement[] }. There is a suggestion to allow type annotations inside binding patterns so if you want to see this you might want to go there and give it a 👍.