feat: export available colors as TS type
This commit is contained in:
parent
1f77953f1a
commit
aefb21012d
2 changed files with 74 additions and 0 deletions
69
index.d.ts
vendored
69
index.d.ts
vendored
|
|
@ -20,6 +20,71 @@ declare const enum LevelEnum {
|
|||
TrueColor = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Available foreground colors for use
|
||||
*/
|
||||
declare type ForegroundColor =
|
||||
| "black"
|
||||
| "red"
|
||||
| "green"
|
||||
| "yellow"
|
||||
| "blue"
|
||||
| "magenta"
|
||||
| "cyan"
|
||||
| "white"
|
||||
| "gray"
|
||||
| "grey"
|
||||
| "blackBright"
|
||||
| "redBright"
|
||||
| "greenBright"
|
||||
| "yellowBright"
|
||||
| "blueBright"
|
||||
| "magentaBright"
|
||||
| "cyanBright"
|
||||
| "whiteBright";
|
||||
|
||||
/**
|
||||
* Available background colors for use
|
||||
*/
|
||||
declare type BackgroundColor =
|
||||
| "bgBlack"
|
||||
| "bgRed"
|
||||
| "bgGreen"
|
||||
| "bgYellow"
|
||||
| "bgBlue"
|
||||
| "bgMagenta"
|
||||
| "bgCyan"
|
||||
| "bgWhite"
|
||||
| "bgGray"
|
||||
| "bgGrey"
|
||||
| "bgBlackBright"
|
||||
| "bgRedBright"
|
||||
| "bgGreenBright"
|
||||
| "bgYellowBright"
|
||||
| "bgBlueBright"
|
||||
| "bgMagentaBright"
|
||||
| "bgCyanBright"
|
||||
| "bgWhiteBright";
|
||||
|
||||
/**
|
||||
* Available colors for use
|
||||
*/
|
||||
declare type Color = BackgroundColor | ForegroundColor;
|
||||
|
||||
/**
|
||||
* Available modifiers for use
|
||||
*/
|
||||
declare type Modifiers =
|
||||
| "reset"
|
||||
| "bold"
|
||||
| "dim"
|
||||
| "italic"
|
||||
| "underline"
|
||||
| "inverse"
|
||||
| "hidden"
|
||||
| "strikethrough"
|
||||
| "visible";
|
||||
|
||||
declare namespace chalk {
|
||||
type Level = LevelEnum;
|
||||
|
||||
|
|
@ -306,6 +371,10 @@ This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
|||
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
||||
supportsColor: chalk.ColorSupport | false;
|
||||
Level: typeof LevelEnum;
|
||||
BackgroundColor: BackgroundColor;
|
||||
ForegroundColor: ForegroundColor;
|
||||
Color: Color;
|
||||
Modifiers: Modifiers;
|
||||
};
|
||||
|
||||
export = chalk;
|
||||
|
|
|
|||
|
|
@ -139,3 +139,8 @@ expectType<string>(chalk.bgWhiteBright`foo`);
|
|||
// -- Complex --
|
||||
expectType<string>(chalk.red.bgGreen.underline('foo'));
|
||||
expectType<string>(chalk.underline.red.bgGreen('foo'));
|
||||
|
||||
// -- Color types ==
|
||||
|
||||
expectType<typeof chalk.Color>('red');
|
||||
expectError<typeof chalk.Color>('hotpink');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue