diff --git a/types/color-namer/color-namer-tests.ts b/types/color-namer/color-namer-tests.ts new file mode 100644 index 0000000000..1328d67221 --- /dev/null +++ b/types/color-namer/color-namer-tests.ts @@ -0,0 +1,24 @@ +import namer = require('color-namer'); + +const colors1 = namer('#ffffff'); + +colors1.basic[0].distance; +colors1.basic[0].hex; +colors1.basic[0].name; +colors1.html; +colors1.ntc; +colors1.pantone; +colors1.roygbiv; +colors1.x11; + +const colors2 = namer('#ffffff', { pick: ['basic', 'html', 'ntc'] }); + +colors2.basic; +colors2.html; +colors2.ntc; + +const colors3 = namer('#ffffff', { omit: ['basic', 'html', 'ntc'] }); + +colors3.pantone; +colors3.roygbiv; +colors3.x11; diff --git a/types/color-namer/index.d.ts b/types/color-namer/index.d.ts new file mode 100644 index 0000000000..f7e9276392 --- /dev/null +++ b/types/color-namer/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for color-namer 1.3 +// Project: https://github.com/zeke/color-namer +// Definitions by: Dmitriy Serdtsev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export = ColorNamer; +export as namespace ColorNamer; + +declare function ColorNamer(color: string, options?: { pick: T[] }): ColorNamer.Colors; +declare function ColorNamer(color: string, options?: { omit: T[] }): ColorNamer.Colors>; + +type Diff = ({[P in T]: P} & {[P in U]: never } & { [x: string]: never })[T]; + +declare namespace ColorNamer { + type Colors = Record; + + type Palette = 'roygbiv' | 'basic' | 'html' | 'x11' | 'pantone' | 'ntc'; + + interface Color { + name: string; + hex: string; + distance: number; + } +} diff --git a/types/color-namer/tsconfig.json b/types/color-namer/tsconfig.json new file mode 100644 index 0000000000..cb048867ee --- /dev/null +++ b/types/color-namer/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "color-namer-tests.ts" + ] +} \ No newline at end of file diff --git a/types/color-namer/tslint.json b/types/color-namer/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/color-namer/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }