我有一个名为RESTConfig.ts的文件,其中包含以下界面和枚举:
export const enum RESTMethod {
POST = "POST",
GET = "GET"
}
export interface RESTConfig {
url: string;
method: RESTMethod;
data: any;
}
我想在另一个类中导入和使用枚举类型,代码如下:
import { RESTConfig, RESTMethod } from './RESTConfig';
class Pipelines {
...
private someMethod() {
let rest: RESTConfig = {
url: "",
method: RESTMethod.POST,
data: {}
}
...
}
...
}
代码经过Linting和转译后运行正常,但运行时出现以下错误:
TypeError: Cannot read property 'POST' of undefined
错误发生在"method: RESTMethod.POST"这一行。
请问我做错了什么?