I'm trying to type globalThis
but can't figure it out. I thought it was working in the past but now it doesn't.
// globalThis.app.tsimport { Platform } from 'react-native';globalThis.app = { isIos: Platform.OS === 'ios',};// Freeze so these can only be defined in this file.Object.freeze(globalThis.app);
// typings/global.d.tsdeclare module globalThis { const app: { isIos: boolean; };}
And at the top level...
// App.tsximport './globalThis.app';console.log(globalThis.app.isIos);
This logs to the console correctly and doesn't display a type error.
But, it also doesn't autocomplete and when I hover over .app
it gives "any" as the type.
What is the correct way to type globalThis?