Why I got error in typescript when I use Object destructuring?
The Javscript is running well. but typescript got error.
fn error:
This expression is not callable.
Not all constituents of type '(() => void) | { bar: () => void; }' are callable.
Type '{ bar: () => void; }' has no call signatures.
bar error:
Property 'bar' does not exist on type '(() => void) | { bar: () => void; }'
const foo = () => {
const fn = () => { console.log('in fn'); };
return [{ bar: () => { console.log('in bar'); } }, fn];
};
const baz = () => {
const [{ bar }, fn] = foo();
fn();
};
baz();
