I use a package that has a function with the following declaration:
const getList: (params?: ListRequestParams | undefined) => Promise<void | {
items: any[];
pageInfo: PageInfo;
}>
I tried to destructure the returned value from a call to this function with:
const {items, pageInfo} = await getList(some_param);
but it does not work probably due to the 'void' part. Using a temp value works, but looks clumsy.
const temp = await getList(some_params);
if(temp !== undefined)
{
const { items, pageInfo } = temp;
}
Just wonder there is better ways for destructuring in this case. Thanks.