Hello StackOverflow community,
I am encountering an issue with my JavaScript code where a global variable is sometimes not defined. I have a configuration class in Angular2 that imports this global variable using 'declare var any'. Within the class, I have a static variable with a ternary operator to check if the global variable exists (!=null) and then set certain statement, but it results in throwing an error: Uncaught ReferenceError: IMPORTED_VAR is not defined. How can I resolve this issue?
declare var IMPORTED_VAR:any;
export class ConfigurationClass {
public static CONF_VAR = IMPORTED_VAR ? IMPORTED_VAR : "SOMETHING";
}