So when I do (window?.innerHeight || 420)
in the case of SSR which translates to
(((_window = window) === null || _window === void 0 ? void 0 : _window.innerHeight) || 420)
I would still get
referenceError: window is not defined
since Javascript has this werid semantics where you have to assign undefined
to something that is not defined or you'd have to resort to using bulky expressino like typeof window === 'undefined'
i.e.
window = typeof window === 'undefined' ? undefined : window
So in the settings of frameworks like nextJs, where global variable is not supported, how can I hack things up to include the above defeintion globally so window's optinonal chainning can reliably work across all places?