mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #31307 from manuth/master
Add types for the "colornames"-module
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import colorNames = require("colornames");
|
||||
|
||||
// $ExpectType Color
|
||||
const color = colorNames("red");
|
||||
|
||||
// $ExpectType string
|
||||
color.value;
|
||||
// $ExpectType boolean | undefined
|
||||
color.css;
|
||||
// $ExpectType boolean | undefined
|
||||
color.vga;
|
||||
// $ExpectType string
|
||||
color.name;
|
||||
|
||||
// $ExpectType Color
|
||||
colorNames.get("blue");
|
||||
// $ExpectType Color[]
|
||||
colorNames.get.all();
|
||||
// $ExpectType Color[]
|
||||
colorNames.get.css();
|
||||
// $ExpectType Color
|
||||
colorNames.get.css("orange");
|
||||
// $ExpectType Color[]
|
||||
colorNames.get.vga();
|
||||
// $ExpectType Color
|
||||
colorNames.get.vga("violet");
|
||||
|
||||
// $ExpectType Color[]
|
||||
colorNames.all();
|
||||
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
// Type definitions for colornames 1.1
|
||||
// Project: https://github.com/timoxley/colornames#readme
|
||||
// Definitions by: Manuel Thalmann <https://github.com/manuth>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Represents a color.
|
||||
*/
|
||||
interface Color {
|
||||
/**
|
||||
* Gets the value of the color.
|
||||
*/
|
||||
value: string;
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the color is a valid `CSS`-color.
|
||||
*/
|
||||
css?: boolean;
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the color is a valid `VGA`-color.
|
||||
*/
|
||||
vga?: boolean;
|
||||
|
||||
/**
|
||||
* Gets the name of the color.
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Povides the functionality to resolve colors of a specific type by its name.
|
||||
*/
|
||||
interface ColorResolver {
|
||||
/**
|
||||
* Gets the color with the specified name.
|
||||
*
|
||||
* @param name
|
||||
* The name of the color to get.
|
||||
*/
|
||||
(name: string): Color;
|
||||
|
||||
/**
|
||||
* Gets all colors.
|
||||
*/
|
||||
(): Color[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the functionality to resolve any kind of color by its name.
|
||||
*/
|
||||
interface GlobalResolver {
|
||||
/**
|
||||
* Gets the color with the specified name.
|
||||
*/
|
||||
(name: string): Color;
|
||||
|
||||
/**
|
||||
* Provides the functionality to query colors.
|
||||
*/
|
||||
get: {
|
||||
/**
|
||||
* Gets the color with the specified name.
|
||||
*
|
||||
* @param name
|
||||
* The name of the color to get.
|
||||
*/
|
||||
(name: string): Color;
|
||||
|
||||
/**
|
||||
* Gets all available colors.
|
||||
*/
|
||||
all(): Color[];
|
||||
|
||||
/**
|
||||
* Provides the functionality to resolve `css`-colors.
|
||||
*/
|
||||
css: ColorResolver;
|
||||
|
||||
/**
|
||||
* Provides the functionality to resolve `vga`-colors.
|
||||
*/
|
||||
vga: ColorResolver;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets all available colors.
|
||||
*/
|
||||
all(): Color[];
|
||||
}
|
||||
|
||||
declare let colorNames: GlobalResolver;
|
||||
export = colorNames;
|
||||
@@ -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",
|
||||
"colornames-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user