I want to pass some environment variables to a front-end app. They are passed via replace as part of the build process, so for example:
if (ENV_IS_PRODUCTION) { ... } will evaluate to: if (false) { ... } in the compiled bundle (so it can be stripped completely by the minifier).
Now I need some way to tell TypeScript that ENV_IS_PRODUCTION is a boolean. I want to use it directly, window.ENV_IS_PRODUCTION would evaluate to window.false so it's not an option.
The furthest I came with it is to declare it locally:
declare const ENV_IS_PRODUCTION: boolean;
But I have no idea how to declare it globally. I tried putting the above local definition into globals.d.ts but it doesn't work. And again, I cannot use window, global, or globalThis. It has to be accessed directly as a variable, without having to import it and without using window/global.