-
-
Notifications
You must be signed in to change notification settings - Fork 950
LevelEnum type error; Cannot access ambient const enums with --isolatedModules #382
Copy link
Copy link
Closed
Description
- Operating System (or Browser): Arch Linux
chalkVersion:3.0.0- Node Version:
13.7.0 - TypeScript Version:
3.7.5
How Do We Reproduce?
- Import
chalkin a TypeScript project - Attempt to build the project with the
--isolatedModulesoption
See minimal repro: https://github.com/MaxMilton/repro-chalk-enum-type
Expected Behaviour
Project builds without type errors.
Actual Behaviour
Type error is thrown due to ambient const enums not supported with the --isolatedModules option.
❯ yarn run build
yarn run v1.21.1
$ tsc --isolatedModules --esModuleInterop index.ts
node_modules/chalk/index.d.ts:403:16 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
403 Level: typeof LevelEnum;
~~~~~~~~~
Found 1 error.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Changing chalk/index.d.ts from...
declare const enum LevelEnum {... to...
declare enum LevelEnum {... resolves the issue. Since chalk.Level is already defined in the source, this change shouldn't impact consumer functionality.
There is a similar issue #363 which took a step towards fixing this but didn't quite get all the way there.
Developers upgrading to Jest v25.1.0 packages are going to run into this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels