Fix colornames default export type definition (#35354)

* update colornames types

* add name

* fix linter errors

* feedback
This commit is contained in:
Benjamin Turner 2019-05-14 13:13:02 -07:00 committed by Nathan Shively-Sanders
parent 3b625a5f37
commit 5f8fe32ce2
2 changed files with 10 additions and 11 deletions

View File

@ -1,19 +1,17 @@
import colorNames = require("colornames");
// $ExpectType string | undefined
colorNames("red");
// $ExpectType string | undefined
colorNames("donkey");
// $ExpectType Color
const color = colorNames("red");
// $ExpectType string
color.value;
const blue = colorNames.get("blue");
// $ExpectType boolean | undefined
color.css;
blue.css;
// $ExpectType boolean | undefined
color.vga;
blue.vga;
// $ExpectType string
color.name;
// $ExpectType Color
colorNames.get("blue");
blue.name;
// $ExpectType Color[]
colorNames.get.all();
// $ExpectType Color[]

View File

@ -1,6 +1,7 @@
// Type definitions for colornames 1.1
// Project: https://github.com/timoxley/colornames#readme
// Definitions by: Manuel Thalmann <https://github.com/manuth>
// Benjamin Turner <https://github.com/blturner>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
@ -53,7 +54,7 @@ interface GlobalResolver {
/**
* Gets the color with the specified name.
*/
(name: string): Color;
(name: string): string | undefined;
/**
* Provides the functionality to query colors.