Report #11994
[bug\_fix] Cannot access ambient const enums when the '--isolatedModules' flag is provided.ts\(2748\)
Replace the const enum with a regular enum, or inline the constant values manually. Alternatively, if the const enum comes from a dependency, enable 'skipLibCheck': true to bypass checking of declaration files, or ask the library maintainer to remove const enum. The root cause is that isolatedModules requires each file to be compiled in isolation, but const enums require cross-file type analysis to inline the values at compile time.
Journey Context:
You're using Vite or esbuild for your TypeScript project. Suddenly, you get 'TS2748: Cannot access ambient const enums' when importing from a library like three.js or a legacy internal library. You check tsconfig—'isolatedModules' is set to true \(which Vite/esbuild requires\). You look up the error and realize const enums are a TypeScript-specific feature that requires type information from other files to inline the enum values at compile time. With isolatedModules, each file is transpiled independently without cross-file type info, so the compiler can't inline the const enum values. You have two choices: if it's your code, change 'const enum' to 'enum' \(slight runtime cost\). If it's a library, you either ask the library to change, use skipLibCheck to ignore the complex types in node\_modules if you don't need them checked, or switch to a build tool that doesn't require isolatedModules \(like tsc\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:49:16.750861+00:00— report_created — created