Type definition improvements

This commit is contained in:
Sindre Sorhus 2018-12-26 02:25:23 +01:00
parent 4726b1bfda
commit cf6615647a
2 changed files with 17 additions and 18 deletions

13
index.d.ts vendored
View file

@ -29,9 +29,8 @@ export interface Options {
enabled?: boolean; enabled?: boolean;
/** /**
* Specify the color support for Chalk. By default, * Specify the color support for Chalk.
* color support is automatically detected based on * By default, color support is automatically detected based on the environment.
* the environment.
*/ */
level?: Level; level?: Level;
} }
@ -91,9 +90,8 @@ export interface Chalk {
enabled: boolean; enabled: boolean;
/** /**
* The color support for Chalk. By default, color * The color support for Chalk.
* support is automatically detected based on the * By default, color support is automatically detected based on the environment.
* environment.
*/ */
level: Level; level: Level;
@ -230,7 +228,8 @@ export interface Chalk {
readonly strikethrough: this; readonly strikethrough: this;
/** /**
* Modifier: Prints the text only when Chalk is enabled. Can be useful for things that are purely cosmetic. * Modifier: Prints the text only when Chalk is enabled.
* Can be useful for things that are purely cosmetic.
*/ */
readonly visible: this; readonly visible: this;

View file

@ -9,7 +9,7 @@ export type Level = $Values<{
TrueColor: 3 TrueColor: 3
}>; }>;
export type ChalkOptions = {| export type Options = {|
enabled?: boolean, enabled?: boolean,
level?: Level level?: Level
|}; |};
@ -24,19 +24,19 @@ export type ColorSupport = {|
export interface Chalk { export interface Chalk {
(...text: string[]): string, (...text: string[]): string,
(text: TemplateStringsArray, ...placeholders: string[]): string, (text: TemplateStringsArray, ...placeholders: string[]): string,
constructor(options?: ChalkOptions): Chalk, constructor(options?: Options): Chalk,
enabled: boolean, enabled: boolean,
level: Level, level: Level,
rgb(r: number, g: number, b: number): Chalk, rgb(red: number, green: number, blue: number): Chalk,
hsl(h: number, s: number, l: number): Chalk, hsl(hue: number, saturation: number, lightness: number): Chalk,
hsv(h: number, s: number, v: number): Chalk, hsv(hue: number, saturation: number, value: number): Chalk,
hwb(h: number, w: number, b: number): Chalk, hwb(hue: number, whiteness: number, blackness: number): Chalk,
bgHex(color: string): Chalk, bgHex(color: string): Chalk,
bgKeyword(color: string): Chalk, bgKeyword(color: string): Chalk,
bgRgb(r: number, g: number, b: number): Chalk, bgRgb(red: number, green: number, blue: number): Chalk,
bgHsl(h: number, s: number, l: number): Chalk, bgHsl(hue: number, saturation: number, lightness: number): Chalk,
bgHsv(h: number, s: number, v: number): Chalk, bgHsv(hue: number, saturation: number, value: number): Chalk,
bgHwb(h: number, w: number, b: number): Chalk, bgHwb(hue: number, whiteness: number, blackness: number): Chalk,
hex(color: string): Chalk, hex(color: string): Chalk,
keyword(color: string): Chalk, keyword(color: string): Chalk,
@ -85,7 +85,7 @@ export interface Chalk {
+bgBlueBright: Chalk, +bgBlueBright: Chalk,
+bgMagentaBright: Chalk, +bgMagentaBright: Chalk,
+bgCyanBright: Chalk, +bgCyanBright: Chalk,
+bgWhiteBrigh: Chalk, +bgWhiteBright: Chalk,
supportsColor: ColorSupport supportsColor: ColorSupport
}; };