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

Add ansi and bgAnsi to TypeScript declaration #369

Merged
merged 1 commit into from Nov 9, 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
17 changes: 17 additions & 0 deletions index.d.ts
Expand Up @@ -213,6 +213,14 @@ declare namespace chalk {
*/
hwb(hue: number, whiteness: number, blackness: number): Chalk;

/**
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.

30 <= code && code < 38 || 90 <= code && code < 98
For example, 31 for red, 91 for redBright.
*/
ansi(code: number): Chalk;

/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
*/
Expand Down Expand Up @@ -266,6 +274,15 @@ declare namespace chalk {
*/
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;

/**
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.

30 <= code && code < 38 || 90 <= code && code < 98
For example, 31 for red, 91 for redBright.
Use the foreground code, not the background code (for example, not 41, nor 101).
*/
bgAnsi(code: number): Chalk;

/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
*/
Expand Down
2 changes: 2 additions & 0 deletions index.test-d.ts
Expand Up @@ -49,13 +49,15 @@ expectType<colorReturn>(chalk.rgb(0, 0, 0));
expectType<colorReturn>(chalk.hsl(0, 0, 0));
expectType<colorReturn>(chalk.hsv(0, 0, 0));
expectType<colorReturn>(chalk.hwb(0, 0, 0));
expectType<colorReturn>(chalk.ansi(30));
expectType<colorReturn>(chalk.ansi256(0));
expectType<colorReturn>(chalk.bgHex('#DEADED'));
expectType<colorReturn>(chalk.bgKeyword('orange'));
expectType<colorReturn>(chalk.bgRgb(0, 0, 0));
expectType<colorReturn>(chalk.bgHsl(0, 0, 0));
expectType<colorReturn>(chalk.bgHsv(0, 0, 0));
expectType<colorReturn>(chalk.bgHwb(0, 0, 0));
expectType<colorReturn>(chalk.bgAnsi(30));
expectType<colorReturn>(chalk.bgAnsi256(0));

// -- Modifiers --
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -261,7 +261,7 @@ The following color models can be used:
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
- `ansi16`
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`


Expand Down