Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix const enum for TypeScript #364

Merged
merged 6 commits into from Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/index.js
Expand Up @@ -223,4 +223,16 @@ chalk.supportsColor = stdoutColor;
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
chalk.stderr.supportsColor = stderrColor;

// For TypeScript
chalk.Level = {
None: 0,
Basic: 1,
Ansi256: 2,
TrueColor: 3,
0: 'None',
1: 'Basic',
2: 'Ansi256',
3: 'TrueColor'
};

module.exports = chalk;
12 changes: 12 additions & 0 deletions test/level.js
Expand Up @@ -43,3 +43,15 @@ test('disable colors if they are not supported', async t => {
const {stdout} = await execa.node(path.join(__dirname, '_fixture'));
t.is(stdout, 'testout testerr');
});

test('chalk.Level enum object', t => {
const {Level} = chalk;
t.is(Level.None, 0);
t.is(Level.Basic, 1);
t.is(Level.Ansi256, 2);
t.is(Level.TrueColor, 3);
t.is(Level[Level.None], 'None');
t.is(Level[Level.Basic], 'Basic');
t.is(Level[Level.Ansi256], 'Ansi256');
t.is(Level[Level.TrueColor], 'TrueColor');
});