I have the following interface and enum in a file RESTConfig.ts:
export const enum RESTMethod {
POST = "POST",
GET = "GET"
}
export interface RESTConfig {
url: string;
method: RESTMethod;
data: any;
}
I want to import and use the enum in another class as such:
import { RESTConfig, RESTMethod } from './RESTConfig';
class Pipelines {
...
private someMethod() {
let rest: RESTConfig = {
url: "",
method: RESTMethod.POST,
data: {}
}
...
}
...
}
Linting and transpiling works fine, but at runtime I get the following error:
TypeError: Cannot read property 'POST' of undefined
on the line "method: RESTMethod.POST".
Can someone tell me what I'm doing wrong?
I just found out the hard way that this can also happen if you have circular imports.