- 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...
... 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.
chalkVersion:3.0.013.7.03.7.5How Do We Reproduce?
chalkin a TypeScript project--isolatedModulesoptionSee 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
--isolatedModulesoption.Changing
chalk/index.d.tsfrom...... to...
... resolves the issue. Since
chalk.Levelis 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.0packages are going to run into this.