get-contrast icon indicating copy to clipboard operation
get-contrast copied to clipboard

types?

Open ryanbuckleyca opened this issue 2 years ago • 1 comments

converting a project to typescript but not able to install get-contrast types. seems there are none?

npm i --save-dev @types/get-contrast
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fget-contrast - Not found
npm ERR! 404 
npm ERR! 404  '@types/get-contrast@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

ryanbuckleyca avatar Jun 15 '22 13:06 ryanbuckleyca

Hi i created a types

// global.d.ts
declare module "get-contrast" {
    type Options = {
        ignoreAlpha: boolean
    }

    export function ratio(colorOne: string, colorTwo: string, options?: Options): string
    export function score(colorOne: string, colorTwo: string, options?: Options): string
    export function isAccessible(colorOne: string, colorTwo: string, options?: Options): boolean
    export function isNotTransparent(color: string, options?: Options): boolean
}

vincent-vade avatar Oct 29 '23 13:10 vincent-vade