diff --git a/index.d.ts b/index.d.ts index b42e4c0..e25ac43 100644 --- a/index.d.ts +++ b/index.d.ts @@ -271,6 +271,6 @@ export interface Chalk { * Order doesn't matter, and later styles take precedent in case of a conflict. * This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`. */ -declare const chalk: Chalk & { supportsColor: ColorSupport }; +declare const chalk: Chalk & { supportsColor: false | ColorSupport }; export default chalk; diff --git a/index.js.flow b/index.js.flow index aac750e..07b0a7f 100644 --- a/index.js.flow +++ b/index.js.flow @@ -14,7 +14,7 @@ export type Options = {| level?: Level |}; -export type ColorSupport = {| +export type ColorSupport = false | {| level: Level, hasBasic: boolean, has256: boolean, diff --git a/index.test-d.ts b/index.test-d.ts index 6cda4da..aa146b4 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -2,7 +2,7 @@ import {expectType} from 'tsd-check'; import chalk, {Level, Chalk, ColorSupport} from '.'; // - Helpers - -type colorReturn = Chalk & {supportsColor: ColorSupport}; +type colorReturn = Chalk & {supportsColor: false | ColorSupport}; // - Level - expectType(Level.None); @@ -11,9 +11,9 @@ expectType(Level.Ansi256); expectType(Level.TrueColor); // - supportsColor - -expectType(chalk.supportsColor.hasBasic); -expectType(chalk.supportsColor.has256); -expectType(chalk.supportsColor.has16m); +expectType(chalk.supportsColor && chalk.supportsColor.hasBasic); +expectType(chalk.supportsColor && chalk.supportsColor.has256); +expectType(chalk.supportsColor && chalk.supportsColor.has16m); // - Chalk - // -- Constructor --