How to import an Enum
Solution 1:
I was missing the export keyword:
export enum EntityStatus {
New = 0,
Active = 1,
Archived = 2,
Trashed = 3,
Deleted = 4
}
Then it worked as expected.
Solution 2:
You will get the same Cannot read property 'Foo' of undefined.
runtime error when you happen to define your Enum in one of the TypeScript Declaration files (*.d.ts
) as these files does not get transpired into JavaScript.
More details with a sample app can be found here.