What is the correct type for event in Checkbox event handler? #2607
-
My code works, but is flagged by TypeScript as having an implicit 'any' type, which I'd like to fix. However, I can't identify the correct type to associate with the event detail passed into the handler for my Checkbox. Here's the relevant handler code:
And here's the TSX where it's invoked from:
I've tried declaring
I'll admit I'm fairly new to TypeScript, so may be overlooking something basic, but if someone could advise on the right way to fix this (and explain why it;s right), I'd be really grateful. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can do this import { Checkbox, CheckboxProps } from '@cloudscape-design/components';
const handleDeleteToggle: CheckboxProps['onChange'] = event => {
...
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply Boris; your suggestion works. it wasn't clear from the Type declarations that this would require a function expression, rather than a declaration. This is an area of TypeScript I'm not yet familiar with, so I'll need to do some homework to understand it better. Thanks again. |
Beta Was this translation helpful? Give feedback.
You can do this