From 3daac759f4ce410664691073d7a16f735e5fe66a Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Wed, 21 Nov 2018 21:46:45 +1100 Subject: [PATCH 1/2] ansicolors: accurate types with recursion support --- types/ansicolors/index.d.ts | 44 +++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/types/ansicolors/index.d.ts b/types/ansicolors/index.d.ts index 6750283895..e82fb47dd7 100644 --- a/types/ansicolors/index.d.ts +++ b/types/ansicolors/index.d.ts @@ -1,8 +1,44 @@ // Type definitions for ansicolors // Project: https://github.com/thlorenz/ansicolors -// Definitions by: rogierschouten +// Definitions by: Benjamin Arthur Lupton // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare var colors: { [index: string]: (s: string) => string; }; -export = colors; +interface Colors extends String { + white: Colors + black: Colors + blue: Colors + cyan: Colors + green: Colors + magenta: Colors + red: Colors + yellow: Colors + brightBlack: Colors + brightRed: Colors + brightGreen: Colors + brightYellow: Colors + brightBlue: Colors + brightMagenta: Colors + brightCyan: Colors + brightWhite: Colors + bgBlack: Colors + bgRed: Colors + bgGreen: Colors + bgYellow: Colors + bgBlue: Colors + bgMagenta: Colors + bgCyan: Colors + bgWhite: Colors + bgBrightBlack: Colors + bgBrightRed: Colors + bgBrightGreen: Colors + bgBrightYellow: Colors + bgBrightBlue: Colors + bgBrightMagenta: Colors + bgBrightCyan: Colors + bgBrightWhite: Colors + open: Colors + close: Colors + colors: Colors +} +declare var colors: Colors +export default colors From aeeaa025d5799c6552a5ff4d77318af4c3c9f009 Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Mon, 3 Dec 2018 20:53:58 +1100 Subject: [PATCH 2/2] ansicolors: support colors as functions --- types/ansicolors/index.d.ts | 73 +++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/types/ansicolors/index.d.ts b/types/ansicolors/index.d.ts index e82fb47dd7..dd1a872e57 100644 --- a/types/ansicolors/index.d.ts +++ b/types/ansicolors/index.d.ts @@ -4,41 +4,42 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Colors extends String { - white: Colors - black: Colors - blue: Colors - cyan: Colors - green: Colors - magenta: Colors - red: Colors - yellow: Colors - brightBlack: Colors - brightRed: Colors - brightGreen: Colors - brightYellow: Colors - brightBlue: Colors - brightMagenta: Colors - brightCyan: Colors - brightWhite: Colors - bgBlack: Colors - bgRed: Colors - bgGreen: Colors - bgYellow: Colors - bgBlue: Colors - bgMagenta: Colors - bgCyan: Colors - bgWhite: Colors - bgBrightBlack: Colors - bgBrightRed: Colors - bgBrightGreen: Colors - bgBrightYellow: Colors - bgBrightBlue: Colors - bgBrightMagenta: Colors - bgBrightCyan: Colors - bgBrightWhite: Colors - open: Colors - close: Colors - colors: Colors + (value: string): string + white: this + black: this + blue: this + cyan: this + green: this + magenta: this + red: this + yellow: this + brightBlack: this + brightRed: this + brightGreen: this + brightYellow: this + brightBlue: this + brightMagenta: this + brightCyan: this + brightWhite: this + bgBlack: this + bgRed: this + bgGreen: this + bgYellow: this + bgBlue: this + bgMagenta: this + bgCyan: this + bgWhite: this + bgBrightBlack: this + bgBrightRed: this + bgBrightGreen: this + bgBrightYellow: this + bgBrightBlue: this + bgBrightMagenta: this + bgBrightCyan: this + bgBrightWhite: this + open: this + close: this + colors: this } -declare var colors: Colors +declare const colors: Colors export default colors