Skip to content

Commit

Permalink
fix(types): extract kleur/colors definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Aug 19, 2020
1 parent 6093124 commit 06923d0
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 92 deletions.
38 changes: 38 additions & 0 deletions colors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
declare function print(input: string | boolean | number): string;
declare function print(input: undefined | void): undefined;
declare function print(input: null): null;
type Colorize = typeof print;

export declare const $: { enabled: boolean };

// Colors
export declare const black: Colorize;
export declare const red: Colorize;
export declare const green: Colorize;
export declare const yellow: Colorize;
export declare const blue: Colorize;
export declare const magenta: Colorize;
export declare const cyan: Colorize;
export declare const white: Colorize;
export declare const gray: Colorize;
export declare const grey: Colorize;

// Backgrounds
export declare const bgBlack: Colorize;
export declare const bgRed: Colorize;
export declare const bgGreen: Colorize;
export declare const bgYellow: Colorize;
export declare const bgBlue: Colorize;
export declare const bgMagenta: Colorize;
export declare const bgCyan: Colorize;
export declare const bgWhite: Colorize;

// Modifiers
export declare const reset: Colorize;
export declare const bold: Colorize;
export declare const dim: Colorize;
export declare const italic: Colorize;
export declare const underline: Colorize;
export declare const inverse: Colorize;
export declare const hidden: Colorize;
export declare const strikethrough: Colorize;
131 changes: 39 additions & 92 deletions kleur.d.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,45 @@
// Originally by: Rogier Schouten <https://github.com/rogierschouten>
// Adapted by: Madhav Varshney <https://github.com/madhavarshney>
declare module 'kleur' {
namespace kleur {
interface Color {
(x: string | number): string;
(): Kleur;
}

interface Kleur {
// Colors
black: Color;
red: Color;
green: Color;
yellow: Color;
blue: Color;
magenta: Color;
cyan: Color;
white: Color;
gray: Color;
grey: Color;

// Backgrounds
bgBlack: Color;
bgRed: Color;
bgGreen: Color;
bgYellow: Color;
bgBlue: Color;
bgMagenta: Color;
bgCyan: Color;
bgWhite: Color;

// Modifiers
reset: Color;
bold: Color;
dim: Color;
italic: Color;
underline: Color;
inverse: Color;
hidden: Color;
strikethrough: Color;
}
declare namespace kleur {
interface Color {
(x: string | number): string;
(): Kleur;
}

let kleur: kleur.Kleur & { enabled: boolean };
export = kleur;
}

declare module 'kleur/colors' {
function print(input: string | boolean | number): string;
function print(input: undefined | void): undefined;
function print(input: null): null;
type Colorize = typeof print;

namespace kleur {
interface Context {
enabled: boolean;
}

interface Kleur {
// Colors
black: Colorize;
red: Colorize;
green: Colorize;
yellow: Colorize;
blue: Colorize;
magenta: Colorize;
cyan: Colorize;
white: Colorize;
gray: Colorize;
grey: Colorize;

// Backgrounds
bgBlack: Colorize;
bgRed: Colorize;
bgGreen: Colorize;
bgYellow: Colorize;
bgBlue: Colorize;
bgMagenta: Colorize;
bgCyan: Colorize;
bgWhite: Colorize;

// Modifiers
reset: Colorize;
bold: Colorize;
dim: Colorize;
italic: Colorize;
underline: Colorize;
inverse: Colorize;
hidden: Colorize;
strikethrough: Colorize;
}
interface Kleur {
// Colors
black: Color;
red: Color;
green: Color;
yellow: Color;
blue: Color;
magenta: Color;
cyan: Color;
white: Color;
gray: Color;
grey: Color;

// Backgrounds
bgBlack: Color;
bgRed: Color;
bgGreen: Color;
bgYellow: Color;
bgBlue: Color;
bgMagenta: Color;
bgCyan: Color;
bgWhite: Color;

// Modifiers
reset: Color;
bold: Color;
dim: Color;
italic: Color;
underline: Color;
inverse: Color;
hidden: Color;
strikethrough: Color;
}


let kleur: kleur.Kleur & { $: kleur.Context };
export = kleur;
}

declare let kleur: kleur.Kleur & { enabled: boolean };
export = kleur;

0 comments on commit 06923d0

Please sign in to comment.