🤖 Merge PR #63034 [kuler] add typings by @LeoDog896

This commit is contained in:
Tristan F
2022-11-01 19:39:42 -04:00
committed by GitHub
parent dc8f2b7ac8
commit 0d1f68b107
4 changed files with 91 additions and 0 deletions

25
types/kuler/index.d.ts vendored Normal file
View 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;

View 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
View 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
View File

@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }