I'm trying to set an value to a variable declared outside from a forEach loop but I'm getting this warn: Identifier 'arr' is never reassigned; use 'const' instead of 'let'.tslint(prefer-const)... When i deploy my code I just get an empty variable
import * as functions from "firebase-functions"
import * as admin from "firebase-admin"
admin.initializeApp()
export const test = functions.https.onRequest(async (req, res) => {
const stores = await admin.firestore().collection('stores').get()
let arr: boolean[] = []
// tslint:disable-next-line: no-void-expression
await stores.forEach(async (store) => {
const sales = await store.ref.collection('sales').get()
arr.push(sales.empty)
})
console.log(arr);
res.status(200).send({
arr: arr
})
})