From 8046089bc6c7cca9a045702231145b56223484df Mon Sep 17 00:00:00 2001 From: Thomas Sauer Date: Sun, 2 Jul 2017 17:26:14 +0200 Subject: [PATCH] Updated typings --- types/index.d.ts | 18 +++++++++++++----- types/test.ts | 7 +++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 0aa3abc..6e0acc5 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -3,19 +3,27 @@ export = chalk; -declare function chalk(...text: (string | number)[]): string; -declare function chalk(text: TemplateStringsArray, ...placeholders: (string | number)[]): string; +declare function chalk(...text: string[]): string; +declare function chalk(text: TemplateStringsArray, ...placeholders: string[]): string; declare namespace chalk { + + export enum ChalkLevel { + Disabled = 0, + Basic = 1, + Extended = 2, + TrueColor = 3 + } + interface ChalkConstructorOptions { enabled?: boolean; - level?: number; + level?: ChalkLevel; } export function constructor(options?: ChalkConstructorOptions): typeof chalk; export let enabled: boolean; - export let level: number; + export let level: ChalkLevel; export const supportsColor: boolean; export const hex: (color: string) => typeof chalk; @@ -50,7 +58,7 @@ declare namespace chalk { export const cyan: typeof chalk; export const white: typeof chalk; export const gray: typeof chalk; - export const grey: typeof chalk; + export const grey: typeof gray; export const blackBright: typeof chalk; export const redBright: typeof chalk; export const greenBright: typeof chalk; diff --git a/types/test.ts b/types/test.ts index cde09c3..c2f20b9 100644 --- a/types/test.ts +++ b/types/test.ts @@ -5,6 +5,7 @@ chalk.red('foo'); chalk.bgRed('foo'); const name = 'Josh'; +const number = 0; chalk`Hello {bold.red ${name}}`; chalk.red`foo`; @@ -15,13 +16,15 @@ chalk.red.bgGreen.underline('foo'); chalk.underline.red.bgGreen('foo'); chalk.grey('foo'); -chalk.red(0); -const ctx = chalk.constructor({level: 1}); +chalk.constructor({level: 1}); +const ctx = chalk.constructor({level: chalk.ChalkLevel.TrueColor }); ctx('foo'); ctx.red('foo'); ctx`foo`; +chalk.level === chalk.ChalkLevel.Extended; + chalk.enabled; chalk.supportsColor; chalk.level;