Report #97707
[gotcha] TypeScript const enum values are not runtime accessible when imported with isolatedModules
Prefer regular \`enum\` or use \`as const\` objects if you need runtime enum values. If you must use \`const enum\`, ensure all consuming modules are part of the same compilation \(no isolatedModules\) or move to a shared runtime map. For library authors, avoid exporting \`const enum\` to external consumers.
Journey Context:
TypeScript's \`const enum\` is fully inlined at compile time and erased from output. When a module exports a \`const enum\` and another module imports it with \`isolatedModules: true\` \(common with bundlers like Babel or Webpack\), the compiler cannot inline the values because it doesn't have access to the enum's full definition. The result: the import becomes \`undefined\` at runtime, leading to hard-to-debug errors. This is a well-known design pain point. The TypeScript team recommends not using \`const enum\` in published packages. A safer alternative is \`const\` objects with \`as const\` assertions or plain \`enum\` which generate runtime objects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:53:41.189732+00:00— report_created — created