diff --git a/index.d.ts b/index.d.ts index 6256ce3..3405ba1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -67,6 +67,45 @@ export interface ColorSupport { has16m: boolean; } +/** + * Available colors for use + */ +export type Color = + "black" + | "red" + | "green" + | "yellow" + | "blue" + | "magenta" + | "cyan" + | "white" + | "gray" + | "grey" + | "blackBright" + | "redBright" + | "greenBright" + | "yellowBright" + | "blueBright" + | "magentaBright" + | "cyanBright" + | "whiteBright" + | "bgBlack" + | "bgRed" + | "bgGreen" + | "bgYellow" + | "bgBlue" + | "bgMagenta" + | "bgCyan" + | "bgWhite" + | "bgBlackBright" + | "bgRedBright" + | "bgGreenBright" + | "bgYellowBright" + | "bgBlueBright" + | "bgMagentaBright" + | "bgCyanBright" + | "bgWhiteBright"; + export interface Chalk { (...text: unknown[]): string; diff --git a/index.js.flow b/index.js.flow index f7e4abc..04690d9 100644 --- a/index.js.flow +++ b/index.js.flow @@ -21,6 +21,45 @@ export type ColorSupport = {| has16m: boolean |}; +/** + * Available colors for use + */ +export type Color = + "black" + | "red" + | "green" + | "yellow" + | "blue" + | "magenta" + | "cyan" + | "white" + | "gray" + | "grey" + | "blackBright" + | "redBright" + | "greenBright" + | "yellowBright" + | "blueBright" + | "magentaBright" + | "cyanBright" + | "whiteBright" + | "bgBlack" + | "bgRed" + | "bgGreen" + | "bgYellow" + | "bgBlue" + | "bgMagenta" + | "bgCyan" + | "bgWhite" + | "bgBlackBright" + | "bgRedBright" + | "bgGreenBright" + | "bgYellowBright" + | "bgBlueBright" + | "bgMagentaBright" + | "bgCyanBright" + | "bgWhiteBright"; + export interface Chalk { (...text: string[]): string, (text: TemplateStringsArray, ...placeholders: mixed[]): string, diff --git a/index.test-d.ts b/index.test-d.ts index 0b26e9c..070ec2e 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,5 @@ import {expectType} from 'tsd-check'; -import chalk, {Level, Chalk, ColorSupport} from '.'; +import chalk, {Level, Chalk, ColorSupport,Color} from '.'; // - Helpers - type colorReturn = Chalk & {supportsColor: ColorSupport}; @@ -15,6 +15,9 @@ expectType(chalk.supportsColor.hasBasic); expectType(chalk.supportsColor.has256); expectType(chalk.supportsColor.has16m); +// - Color - +expectType("red"); + // - Chalk - // -- Instance -- expectType(new chalk.Instance({level: 1}));