Issues with exporting and importing enums
Author: glazarCreated Jul 28, 2017Updated Aug 26, 2025
Labels:man_shrugging: Needs More Info
TypeScript Version: 2.4.1
Code
file1.ts
export enum Colors {
Red = "RED",
Green = "GREEN",
Blue = "BLUE"
}
export enum Numbers {
ONE = 1,
TWO = 2
}
file2.ts
import { Colors, Numbers } from "./file1";Expected behavior: Colors and Numbers should not be undefined in file2. Colors should be:
{
Red: "RED",
Green: "GREEN",
Blue: "BLUE"
}Numbers should be
{
ONE: 1,
TWO: 2
1: "ONE"
2: "TWO"
}Actual behavior: Colors and Numbers are undefined. Any enum entry requested fail with "Cannot read property 'enum entry' of undefined". It seems that this only occurs in case of a circular dependency. If you remove the circular dependency everything seems to work fine.
Source: kulshekhar/ts-jest