LevelEnum type error; Cannot access ambient const enums with --isolatedModules #382
Closed
Description
- Operating System (or Browser): Arch Linux
chalk
Version:3.0.0
- Node Version:
13.7.0
- TypeScript Version:
3.7.5
How Do We Reproduce?
- Import
chalk
in a TypeScript project - Attempt to build the project with the
--isolatedModules
option
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.
Metadata
Assignees
Labels
No labels