General coding issue: TypeScript compiler static check strictNullChecks to differentiate undefined vs. null #1742
danielweck
started this conversation in
Developer corner
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
See WIP PR:
#475
(broken build)
Example of potential fatal bug(crash):
https://github.com/readium/readium-desktop/blob/3ffe94ac5170b0454cc1f1c208fa348ea925cbcd/src/renderer/components/publication/Cover.tsx#L40-L46
...when
this.props.publication.customCover
isnull
,colors === undefined
will not match, resulting incolors
remainingnull
, and the rest of the code crashing. This could be detected ifstrictNullChecks
was enabled in the TypeScript compiler settings (see the aforementioned WIP PR), but unfortunately this would currently break a huge amount of Thorium code, so we currently have to accept some degree of uncertainty (no static checks), and/or rely on unit-tests, and programmer's awareness (thus why I am filing this issue).Beta Was this translation helpful? Give feedback.
All reactions