I want to set a global variable in react native. It is neccessary and seems like only option in my particular usecase. I'm using typescript with my project. The problem is typescript complains when I set something like global.foo = bar;
with the error "Property 'foo' does not exist on type 'typeof globalThis'." I have tried to create a declaration file like this -
declare module NodeJS { export interface Global { foo: any; }}
and also with some other methods that I found online for react native or NodeJS. None seem to be working. Do anyone have any idea why this is not working. I have declared other modules in the same fashion and they all are working except the global one. Why?