When using (window?.innerHeight || 420)
for server-side rendering (SSR), the translation would be
(((_window = window) === null || _window === void 0 ? void 0 : _window.innerHeight) || 420)
However, this could result in a
referenceError: window is not defined
This issue stems from JavaScript's unique semantics where you must assign undefined
if something is not defined, or use a complex expression like typeof window === 'undefined'
For frameworks like Next.js that do not support global variables, how can I globally define the necessary code snippet to enable window's optional chaining feature consistently?