Hello everyone, I have the below code written in TypeScript
const {
data: { pageCollection }
} = await apolloClient.query<PageSlugsQuery>({ query: GET_PAGE_SLUGS })
( [...(pageCollection?.items ?? [])].forEach((page) => {
console.log('PAGEEE', page)
}))
When I try to use the second line it shows an error message saying
Block scoped variable pageCollection can not be used before its declaration
However, if I remove the brackets from the second line like this:
[...(pageCollection?.items ?? [])].forEach((page) => {
console.log('PAGEEE', page)
})
I then receive a different error message saying Cannot find name 'forEach'.
Does anyone have any idea what could potentially be causing this issue?