mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #63034 [kuler] add typings by @LeoDog896
This commit is contained in:
25
types/kuler/index.d.ts
vendored
Normal file
25
types/kuler/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for kuler 2.0
|
||||
// Project: https://github.com/3rd-Eden/kuler
|
||||
// Definitions by: Tristan F. <https://github.com/LeoDog896>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface KulerInstance {
|
||||
prefix: string;
|
||||
suffix: string;
|
||||
text: string;
|
||||
/** Parse a hex color string and parse it to it's RGB equiv. */
|
||||
hex: (color: string) => [number, number, number];
|
||||
/** Transform a 255 RGB value to an RGV code. */
|
||||
rgb: (r: number, g: number, b: number) => string;
|
||||
/** Turns RGB 0-5 values into a single ANSI code. */
|
||||
ansi: (r: number, g: number, b: number) => string;
|
||||
/** Marks an end of color sequence. */
|
||||
reset: () => string;
|
||||
/** Colour the terminal using CSS. */
|
||||
style: (color: string) => string;
|
||||
}
|
||||
|
||||
declare function kuler(text: string, color: string): string;
|
||||
declare function kuler(text: string): KulerInstance;
|
||||
|
||||
export = kuler;
|
||||
42
types/kuler/kuler-tests.ts
Normal file
42
types/kuler/kuler-tests.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import kuler = require("kuler");
|
||||
|
||||
// $ExpectType string
|
||||
kuler("test").style("red");
|
||||
|
||||
// @ts-expect-error
|
||||
kuler("test").style(new Symbol(5));
|
||||
|
||||
// $ExpectType string
|
||||
kuler("test", "red");
|
||||
|
||||
// @ts-expect-error
|
||||
kuler("test", new Symbol(5));
|
||||
|
||||
const kulerInstance = kuler("test");
|
||||
|
||||
// $ExpectType string
|
||||
kulerInstance.text;
|
||||
|
||||
// $ExpectType string
|
||||
kulerInstance.ansi(1, 2, 3);
|
||||
|
||||
// $ExpectType [number, number, number]
|
||||
kulerInstance.hex("#ffffff");
|
||||
|
||||
// $ExpectType string
|
||||
kulerInstance.rgb(1, 2, 3);
|
||||
|
||||
// $ExpectType string
|
||||
kulerInstance.reset();
|
||||
|
||||
// $ExpectType string
|
||||
kulerInstance.style("red");
|
||||
|
||||
// $ExpectType string
|
||||
kulerInstance.suffix;
|
||||
|
||||
// $ExpectType string
|
||||
kulerInstance.prefix;
|
||||
|
||||
// @ts-expect-error
|
||||
kulerInstance.ansi(new Symbol(5), 2, 3);
|
||||
23
types/kuler/tsconfig.json
Normal file
23
types/kuler/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"kuler-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/kuler/tslint.json
Normal file
1
types/kuler/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "@definitelytyped/dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user