I have a class containing global values that I am declaring as static in typescript.
It looks like this:
export default class Globals {
// All members should be public static - no instantiation required
public static GraphAPIToken: null
public static APP_ID: "appidstringhere"
public static APP_SECRET: "thisisasecret"
public static TOKEN_ENDPOINT: "https://login.microsoftonline.com/aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeeeeee/oauth2/v2.0/token"
public static MS_GRAPH_SCOPE: "https://graph.microsoft.com/.default"
}
After compilation to js using TSC (Typescript 3.7.3) it results in the following:
"use strict";
exports.__esModule = true;
var Globals = /** @class */ (function () {
function Globals() {
}
return Globals;
}());
exports["default"] = Globals;
My question is, what happened to my members!?
Any ideas welcome :)
It looks to me that you're declaring the type of your static variables here as the intended values of your static variables. For example:
public static APP_ID: "appidstringhere"
which says that APP_ID
is of type "appidstringhere"
, when you should be saying:
public static APP_ID: string = "appidstringhere"
which says that APP_ID
is of type string
, and has value "appidstringhere"
.