Merge pull request #32094 from BendingBender/hex-rgb

[hex-rgb] Add types
This commit is contained in:
Daniel Rosenwasser
2019-01-14 14:24:15 -08:00
committed by GitHub
4 changed files with 52 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
import hexRgb = require('hex-rgb');
hexRgb('#cd2222cc'); // $ExpectType RgbaObj
hexRgb('#cd2222cc', { format: 'array' }); // $ExpectType [number, number, number, number]
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for hex-rgb 3.0
// Project: https://github.com/sindresorhus/hex-rgb#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = hexRgb;
declare function hexRgb(hex: string): hexRgb.RgbaObj;
declare function hexRgb(hex: string, options: hexRgb.Options): hexRgb.RgbaArr;
declare namespace hexRgb {
interface Options {
format: 'array';
}
interface RgbaObj {
red: number;
green: number;
blue: number;
alpha: number;
}
type RgbaArr = [number, number, number, number];
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"hex-rgb-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }