ProtonMail / WebClients

Monorepo hosting the proton web clients
GNU General Public License v3.0
4.27k stars 545 forks source link

TypeError in `WelcomePaneBanner.tsx` breaks `@applications/mail` for some reason #255

Closed Nekonyx closed 2 years ago

Nekonyx commented 2 years ago

If filteredOptions is an empty array: https://github.com/ProtonMail/WebClients/blob/8d7f8a902034405988bd70431c714e9fdbb37a1d/applications/mail/src/app/components/view/WelcomePaneBanner.tsx#L324

Then random element from it throws an exception later: https://github.com/ProtonMail/WebClients/blob/8d7f8a902034405988bd70431c714e9fdbb37a1d/applications/mail/src/app/components/view/WelcomePaneBanner.tsx#L326

TypeError: Cannot read properties of undefined (reading 'id')
    at WelcomePaneBanner.tsx:334
    at WelcomePaneBanner.tsx:339
    at fk (react-dom.production.min.js:262)
    at R.unstable_runWithPriority (scheduler.production.min.js:18)
    at gg (react-dom.production.min.js:122)
    at Oj (react-dom.production.min.js:261)
    at react-dom.production.min.js:261
    at V (scheduler.production.min.js:16)
    at MessagePort._e.port1.onmessage (scheduler.production.min.js:12)

image

vladimiry commented 2 years ago

I'd suggest to consider enabling the compilerOptions.noUncheckedIndexedAccess flag in the https://github.com/ProtonMail/WebClients/blob/main/tsconfig.base.json file. This would allow squeezing more value out of the TypeScript. So the issue like this would likely be spotted by a compiler as the randomOption var will be treated as "possibly undefined".

Nekonyx commented 2 years ago

Any updates? I can't check my emails for about a week. image

mmso commented 2 years ago

Thank you for the report @Nekonyx. We will push something today for this.

Correction: Probably not today. Tomorrow more likely

Nekonyx commented 2 years ago

Fixed in [9364a28f42605150cffaa936e5abb837cd0cd7b9] Now it works, thanks 😄