I need to type handleFoo with MyType['foo'].
type MyType {
foo: () => void
}
const Comp: React.FunctionComponent<{}> = () => {
function handleFoo() {}
return ...
}
I don't want to use Anonymous function like const handleFoo: MyType['foo'] = () => {}
I also tried <MyType['foo']>function handleFoo() {} like recommended here but it's not working in tsx (Operator '>' cannot be applied to types 'string[]')
const foo: MyType["foo"] = function () {...}? Otherwise you have to type the parameters and return value separately.function handleFoo(...args: Parameters<MyType["foo"]>): ReturnType<MyType["foo"]> {}lol you're right that would technically work, verbose and funky af tho