Closed nblthree closed 4 years ago
Here's a colorthief.d.ts
that works for me. I put it in src/types
and typescript picked it up automatically.
declare module 'colorthief' {
type Color = [number, number, number];
export default class ColorThief {
getColor: (img: HTMLImageElement | null) => Color;
getPalette: (img: HTMLImageElement | null) => Color[];
}
}
version with optional parameters:
declare module 'colorthief' {
export type RGBColor = [number, number, number];
export default class ColorThief {
getColor: (img: HTMLImageElement | null, quality: number=10) => RGBColor;
getPalette: (img: HTMLImageElement | null, colorCount: number=10, quality: number=10) => RGBColor[];
}
}
getPalette
can return null
This is what I've been using for over 4 months, create a file colorthief.d.ts
in your source directory, a d.ts
file only contains type definitions:
declare module "colorthief" {
export type RGBColor = [number, number, number]
export default class ColorThief {
getColor: (
img: HTMLImageElement | null,
quality: number = 10,
) => RGBColor | null
getPalette: (
img: HTMLImageElement | null,
colorCount: number = 10,
quality: number = 10,
) => RGBColor[] | null
}
}
Why closed the issue? These are great type definitions here but I'd really love if they actually existed on the real package!
unfortunately it doesn't exist