diff --git a/types/color/color-tests.ts b/types/color/color-tests.ts index ac79ea42e9..17d4752ead 100644 --- a/types/color/color-tests.ts +++ b/types/color/color-tests.ts @@ -1,7 +1,7 @@ import Color = require('color'); -const color: Color = new Color("white"); -const colorOther: Color = new Color("black"); +const color: Color<"white"> = new Color("white"); +const colorOther: Color<"black"> = new Color("black"); const colorRGB: Color = new Color({ r: 0, g: 0, b: 0 }, "rgb"); const colorInt: Color = new Color(0x000000); const colorWithoutNew: Color = Color(0x000000); diff --git a/types/color/index.d.ts b/types/color/index.d.ts index 716b8a9dcf..2f14636703 100644 --- a/types/color/index.d.ts +++ b/types/color/index.d.ts @@ -1,16 +1,18 @@ // Type definitions for color 3.0 // Project: https://github.com/qix-/color#readme -// Definitions by: Junyoung Clare Jang , James W. Lane +// Definitions by: Junyoung Clare Jang +// James W. Lane +// Adam Haglund // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 3.7 import convert = require('color-convert'); type ColorParam = Color | string | ArrayLike | number | { [key: string]: any }; -interface Color { +interface Color { toString(): string; - toJSON(): Color; + toJSON(): Color; string(places?: number): string; percentString(places?: number): string; array(): number[]; @@ -65,9 +67,9 @@ interface Color { b(): number; b(val: number): Color; keyword(): string; - keyword(val: string): Color; + keyword(val: V): Color; hex(): string; - hex(val: string): Color; + hex(val: V): Color; rgbNumber(): number; luminosity(): number; contrast(color2: Color): number; @@ -102,8 +104,8 @@ interface Color { } interface ColorConstructor { - (obj?: ColorParam, model?: keyof (typeof convert)): Color; - new(obj?: ColorParam, model?: keyof (typeof convert)): Color; + (obj?: T, model?: keyof (typeof convert)): Color; + new(obj?: T, model?: keyof (typeof convert)): Color; rgb(...val: number[]): Color; rgb(color: ColorParam): Color; hsl(...val: number[]): Color;