Fix TypeScript types for supportsColor which is top‑level only (#342)

Co-Authored-By: Dimitri Benin <BendingBender@users.noreply.github.com>
This commit is contained in:
ExE Boss 2019-05-11 10:04:20 +02:00 committed by Sindre Sorhus
parent d3be9c65b1
commit b3e9b91405
2 changed files with 79 additions and 60 deletions

View file

@ -1,8 +1,8 @@
import {expectType} from 'tsd';
import {expectType, expectError} from 'tsd';
import chalk = require('.');
// - Helpers -
type colorReturn = chalk.Chalk & {supportsColor: chalk.ColorSupport};
type colorReturn = chalk.Chalk & {supportsColor?: never};
// - Level -
expectType<number>(chalk.Level.None);
@ -15,6 +15,9 @@ expectType<boolean>(chalk.supportsColor.hasBasic);
expectType<boolean>(chalk.supportsColor.has256);
expectType<boolean>(chalk.supportsColor.has16m);
// -- `supportsColor` is not a member of the Chalk interface --
expectError(chalk.reset.supportsColor);
// - Chalk -
// -- Instance --
expectType<chalk.Chalk>(new chalk.Instance({level: 1}));