I am trying to define global variables that are accessible from, and modifiable by any Component or Injectable. I do not want to create this as a separate class and have it imported to places where it’s being used. Rather, I would like it to be accessible without it being a property of a class or linked to a particular namespace. I’ve experimented with placing these variables within the declarations.d.ts file, and although the editor is able to detect it properly, during run time it produces Error: Undefined
. My declarations.d.ts file looks something like this:
declare module '*';
declare module 'global' {
const CLIENT_ID: string = 'ABCDEF';
const CLIENT_SECRET: string = 'ABC123';
const SERVER_URL: string = 'https://fjekjqekewqjkwqj.tk';
var ACCESS_TOKEN: string;
var SERIES_ID: string;
interface LatLngLiteral {
lat: number;
lng: number;
}
interface LatLngBoundsLiteral {
east: number;
north: number;
south: number;
west: number;
}
}