if (!challengeType) {
const { brawl, fight }: any = await userModel
.findOneAndUpdate(
{ _id: req.userData._id },
{ $inc: { 'fight.remaining': -1 } },
{ 'new': true }
)
} else {
const { brawl, fight }: any = await userModel
.findOneAndUpdate(
{ _id: req.userData._id },
{ $inc: { 'brawl.remaining': -1 } },
{ 'new': true }
)
}
// typescript error here
// "Cannot find name brawl", and "Cannot find name fight"
console.log(brawl, fight)
not sure why typescript cannot find name brawl and fight, it could be a problem with typescript error handling in the case of if else statements,
but if script is running, no problem has occurred.