我有一个包含在打字稿中声明为静态的全局值的类。
看起来像这样:
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"
}
使用TSC(Typescript 3.7.3)编译为js后,结果如下:
"use strict";
exports.__esModule = true;
var Globals = /** @class */ (function () {
function Globals() {
}
return Globals;
}());
exports["default"] = Globals;
我的问题是,我的会员怎么了!?
任何想法欢迎:)
在我看来,您是在这里将静态变量的类型声明为静态变量的预期值。例如:
public static APP_ID: "appidstringhere"
当您应该说:时,该APP_ID
类型是"appidstringhere"
,
public static APP_ID: string = "appidstringhere"
它说APP_ID
是类型的string
,并且具有价值"appidstringhere"
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句