Skip to content

Add type definitions #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 145 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
838ee59
Add some types
bijela-gora Apr 5, 2022
25494d7
Add types for random function
bijela-gora Apr 10, 2022
93956fa
Fix hsl shape
bijela-gora Apr 10, 2022
68d4e1f
Add types for displayable
bijela-gora Apr 10, 2022
4be690f
Fix typo
bijela-gora Apr 10, 2022
d3be690
Improve readability
bijela-gora Apr 10, 2022
8a0f9e2
Add types for round function
bijela-gora Apr 10, 2022
8c3434c
Add kind of tests for types
bijela-gora Apr 10, 2022
cf1e7e5
Add types for blend function
bijela-gora Apr 10, 2022
244a90d
More accurate type for type parameter ob blend function
bijela-gora Apr 10, 2022
df783d5
Add types for 'average' function
bijela-gora Apr 10, 2022
6702c35
More accurate type for 'random' function
bijela-gora Apr 10, 2022
8491152
Add types for lab color
bijela-gora Apr 10, 2022
73d2e09
Add types for 'converter' function
bijela-gora Apr 10, 2022
c78363d
Add some types
bijela-gora Apr 10, 2022
580a80e
Add types for a98 colors
bijela-gora Apr 10, 2022
67f3c28
Add types for cubehelix color
bijela-gora Apr 10, 2022
c5ac822
Add types for dlab color
bijela-gora Apr 10, 2022
6710f4a
Add more types
bijela-gora Apr 10, 2022
9150ec2
Add types for fixup functions
bijela-gora Apr 10, 2022
086934b
Add types for hsi color
bijela-gora Apr 10, 2022
4295553
Add some types
bijela-gora Apr 10, 2022
5d68735
Add types for hsv
bijela-gora Apr 10, 2022
9adf04f
Add types for hwb color
bijela-gora Apr 10, 2022
ac770b6
Add types for luv color
bijela-gora Apr 11, 2022
15104df
Add types for lchuv color
bijela-gora Apr 11, 2022
fe7198b
Add types for lch and lch65
bijela-gora Apr 11, 2022
5d85485
Add function for easing functions
bijela-gora Apr 11, 2022
0fb67d8
Add function for 'samples' functions
bijela-gora Apr 11, 2022
41f36c3
Update types
bijela-gora Apr 11, 2022
1c5bff8
Add types for jab color
bijela-gora Apr 11, 2022
2ea3ee5
Add types for jhc color Bijela Gora
bijela-gora Apr 11, 2022
e40338a
Fix types for Lch65
bijela-gora Apr 11, 2022
e7568f6
Add types to Color union
bijela-gora Apr 11, 2022
1945859
Add okhsl color types definition
bijela-gora Apr 11, 2022
81d7dd1
Add types for yiq color
bijela-gora Apr 11, 2022
ec44325
Add more types
bijela-gora Apr 11, 2022
9962141
Add more types
bijela-gora Apr 11, 2022
df8ee6f
Add more types
bijela-gora Apr 11, 2022
be75aad
Add index.d.ts
bijela-gora Apr 11, 2022
57f8b84
Fix a98 type
bijela-gora Apr 11, 2022
3c0cfe8
Fix hwb type
bijela-gora Apr 11, 2022
9b3cffc
Fix okhsv type
bijela-gora Apr 11, 2022
8c14105
Fix yiq type
bijela-gora Apr 11, 2022
ab72c6e
Add types for 'clamp' functions
bijela-gora Apr 11, 2022
6df7e4b
Add types for 'deficiency' functions
bijela-gora Apr 11, 2022
7507afb
Add types for 'map' and 'filter' functions
bijela-gora Apr 12, 2022
74b100b
Add types for wcag file
bijela-gora Apr 12, 2022
a2f5330
Add more types
bijela-gora Apr 12, 2022
b6bc11e
Add more types
bijela-gora Apr 12, 2022
8bba16c
Add more types
bijela-gora Apr 12, 2022
74647a9
Add types for parseTransparent function
bijela-gora Apr 12, 2022
772daba
Add more types
bijela-gora Apr 12, 2022
e2e164d
Fix types for 'interpolate' functions
bijela-gora Apr 12, 2022
e666a33
Remove todo comment
bijela-gora Apr 12, 2022
cafefed
Update types for 'prepare' function
bijela-gora Apr 12, 2022
7b80b3e
Minor change
bijela-gora Apr 12, 2022
cf90336
Delete dead code
bijela-gora Apr 12, 2022
f53dbef
Remove comments in tsconfig.json
bijela-gora Apr 12, 2022
9718f24
Remove unnecessary step
bijela-gora Apr 12, 2022
f738467
Simplify color space types
bijela-gora Apr 12, 2022
4905e73
Update for index-fn.js
bijela-gora Apr 13, 2022
a73ae10
Improve type definition for 'random' function
bijela-gora Apr 13, 2022
5a52ee9
Improve types for 'blend' function
bijela-gora Apr 14, 2022
99a274d
Improve types for 'average' function
bijela-gora Apr 14, 2022
f4ff70d
Improve 'converter' function type
bijela-gora Apr 14, 2022
ec1c638
Fix an issue when color is string and mode is null
bijela-gora Apr 14, 2022
183aa2e
Remove leftovers
bijela-gora Apr 14, 2022
ddb2e88
Improve mapper function type
bijela-gora Apr 15, 2022
cad56c8
Add tests for type definition of 'random' function
bijela-gora Apr 14, 2022
fcc390d
Improve script a little bit
bijela-gora Apr 14, 2022
b343ca8
Add tests for blend function
bijela-gora Apr 14, 2022
945254d
Improve types for 'average' function
bijela-gora Apr 14, 2022
58ab198
Fix types for 'blend' function
bijela-gora Apr 14, 2022
08eaa54
Improve 'converter' function type
bijela-gora Apr 14, 2022
6223f17
Update type checks for mapper function
bijela-gora Apr 15, 2022
0b5135a
Add tests for prepare function
bijela-gora Apr 15, 2022
c77099a
Simplify types for clamp functions
bijela-gora Apr 15, 2022
a53d67c
Remove file in which I checked type definitions
bijela-gora Apr 15, 2022
8d67c64
Remove unused import
bijela-gora Apr 15, 2022
c7217f7
First file moved from snapshot testing to check-dts
bijela-gora Apr 15, 2022
80475d3
Second file moved from snapshot testing to check-dts
bijela-gora Apr 15, 2022
feae995
Move third file from snapshot testing to check-dts
bijela-gora Apr 15, 2022
a692233
Move 4th file from snapshot testing to check-dts
bijela-gora Apr 15, 2022
8e4b5dd
Remove unused imports
bijela-gora Apr 15, 2022
5d09757
Migrate what is left from snapshot testing to check-dts
bijela-gora Apr 15, 2022
f3c1da0
Remove comments
bijela-gora Apr 15, 2022
e738a8f
Remove unnecessary dependencies
bijela-gora Apr 19, 2022
5a6c73e
Add example
bijela-gora Apr 19, 2022
3b909f9
Remove prepare script because I see it in logs
bijela-gora May 7, 2022
521d221
Fix config and some types
bijela-gora May 10, 2022
03bcf5f
Add fn.d.ts file to allow to import with 'culori/fn'
bijela-gora May 10, 2022
ae876b9
Remove check-dts command run because it is not stable
bijela-gora May 10, 2022
8c14058
Add todo comment
bijela-gora May 10, 2022
e697e34
Add fn.d.ts to files which should be published
bijela-gora May 10, 2022
beac4cc
Remove unused type
bijela-gora May 11, 2022
c9c4fe8
Export useful input types
bijela-gora May 11, 2022
cfe074a
Add some definitions
bijela-gora May 11, 2022
3f4edd6
Add one more definition
bijela-gora May 11, 2022
d513433
Check-dts does not support "extends" property of tsconfig
bijela-gora May 11, 2022
605efb7
Temp commit to show the issue
bijela-gora May 11, 2022
35c3439
Revert "Temp commit to show the issue"
bijela-gora May 11, 2022
5860ac2
Fix config
bijela-gora May 11, 2022
8083505
Reduce noise
bijela-gora May 11, 2022
4643b3b
Add one more check
bijela-gora May 11, 2022
6f37434
Add one more definition.d.ts
bijela-gora May 11, 2022
ce72687
Add one more definition.d.ts
bijela-gora May 12, 2022
fd7cca9
Replace 'import type' with 'import'
bijela-gora May 12, 2022
7f13323
Add one more definition.d.ts
bijela-gora May 12, 2022
dc317d7
Add one more definition.d.ts
bijela-gora May 12, 2022
da59914
Add one more definition.d.ts
bijela-gora May 12, 2022
58c9c49
Add one more definition.d.ts
bijela-gora May 12, 2022
f2d5f77
Add one more definition.d.ts
bijela-gora May 12, 2022
f9ca781
Fix definition types
bijela-gora May 12, 2022
a5af4b3
Add one more definition.d.ts
bijela-gora May 12, 2022
7ca7c29
Add one more definition.d.ts
bijela-gora May 12, 2022
65fb8c9
Add one more definition.d.ts
bijela-gora May 12, 2022
06ddb25
Add one more definition.d.ts
bijela-gora May 12, 2022
6c4d8b1
Remove '.js' in imports in .d.ts files
bijela-gora May 12, 2022
400938d
Remove unused types
bijela-gora May 12, 2022
220c8cb
Add one more definition.d.ts
bijela-gora May 13, 2022
64a642f
More accurate type of 'convertLabToLch' function
bijela-gora May 13, 2022
5343d02
More accurate type of 'convertLrgbToRgb' function
bijela-gora May 13, 2022
cb675e9
Add test for convertLrgbToRgb function type
bijela-gora May 13, 2022
1bd15ee
Add one more definition.d.ts
bijela-gora May 13, 2022
6e4e6e8
Add one more definition.d.ts
bijela-gora May 13, 2022
3ee48da
Add one more definition.d.ts
bijela-gora May 13, 2022
0d96334
Remove '.js' in imports in .d.ts files
bijela-gora May 13, 2022
adc89c6
Replace 'import type' with import in .d.ts files
bijela-gora May 13, 2022
dbcd0bd
Add types for modes.js
bijela-gora May 13, 2022
53804f1
More accurate type def for converter factory
bijela-gora May 13, 2022
c9a4fda
Increasing the accuracy of formatter types
bijela-gora May 13, 2022
b76810c
Increase the accuracy of formatters types
bijela-gora May 13, 2022
49417eb
Add types for named colors
bijela-gora May 13, 2022
3714acf
Fix formatters types
bijela-gora May 13, 2022
3370d4c
Small update
bijela-gora May 13, 2022
86bc62f
Change an order of types
bijela-gora May 13, 2022
86319c2
Make the ConvertFn type a little more convenient
bijela-gora May 13, 2022
e1303d8
Add .idea/ to gitignore
bijela-gora May 16, 2022
5f8fa2d
All 'h' channels can be not assigned
bijela-gora May 16, 2022
d810061
Add OKLCH & LCH Color Picker to the list of products using Culori
bijela-gora Jan 8, 2023
5cfb5f9
Fix copy&paste typo
bijela-gora Mar 8, 2023
effad4b
Fix type tests
bijela-gora Mar 9, 2023
d44cd8b
Remove unused import statements
bijela-gora Mar 9, 2023
7c13fef
Add two tests
bijela-gora Mar 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.sublime-workspace
.idea/
.DS_Store
build/
bundled/
Expand Down
23 changes: 23 additions & 0 deletions check-dts/average.errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { average } from '../src/average';
import type { Rgb } from '../src/rgb/types';

// THROWS Expected 1-3 arguments, but got 0.
const c1 = average();

// THROWS Argument of type '[]' is not assignable to parameter of type 'NonEmptyArray<string | Color>'.
const c2 = average([]);

// THROWS No overload matches this call.
const c3: Rgb = average(['#ff0000', '#0000ff'], undefined, {
r: 1
});

// THROWS No overload matches this call.
const c4: Rgb = average(['#ff0000', '#0000ff'], 'hsl', {
r: () => 1
});

// THROWS Type 'Hsl' is missing the following properties from type 'Rgb': r, g, b
const c5: Rgb = average(['#ff0000', '#0000ff'], 'hsl', {
h: () => 1
});
20 changes: 20 additions & 0 deletions check-dts/average.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { average } from '../src/average';
import type { Rgb } from '../src/rgb/types';
import type { Lch } from '../src/lch/types';
import type { Oklab } from '../src/oklab/types';

const c1: Rgb = average(['#ff0000', '#0000ff']);

const c2: Lch = average(['#ff0000', '#0000ff'], 'lch');

const c3: Lch = average(['#ff0000', '#0000ff'], 'lch', _ => 1);

const c4: Rgb = average(['#ff0000', '#0000ff'], undefined, _ => 1);

const c5: Rgb = average(['#ff0000', '#0000ff'], undefined, {
r: _ => 1
});

const c6: Oklab = average(['#ff0000', '#0000ff'], 'oklab', {
b: _ => 1
});
17 changes: 17 additions & 0 deletions check-dts/blend.errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import blend from '../src/blend';
import type { Rgb } from '../src/rgb/types';

// THROWS Argument of type '[]' is not assignable to parameter of type 'NonEmptyArray<string | Color>'.
const c1 = blend([]);

// THROWS Type 'number' is not assignable to type 'string | Color'.
const c2: Rgb = blend([12312]);

const c3: Rgb = blend(
['white', 'rgba(0, 0, 0, 0.5)'],
// THROWS Argument of type '"darke"' is not assignable to parameter of type 'BlendTypes | BlendingFunction'.
'darke'
);

// THROWS Type 'Jab' is missing the following properties from type 'Rgb': r, g
const c4: Rgb = blend(['white', 'rgba(0, 0, 0, 0.5)'], 'darken', 'jab');
15 changes: 15 additions & 0 deletions check-dts/blend.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import blend from '../src/blend';
import type { Rgb } from '../src/rgb/types';
import type { Jab } from '../src/jab/types';

const c1: Rgb = blend([
{ mode: 'rgb', r: 1, g: 0, b: 0, alpha: 0.5 },
{ mode: 'rgb', r: 0, g: 0, b: 1, alpha: 0.5 }
]);
const c2: Rgb = blend(['white', 'rgba(0, 0, 0, 0.5)']);

const c3: Rgb = blend(['white', 'rgba(0, 0, 0, 0.5)'], 'darken');
const c4: Rgb = blend(['white', 'rgba(0, 0, 0, 0.5)'], b => b * 2);
const c5: Rgb = blend(['white', 'rgba(0, 0, 0, 0.5)'], (b, s) => b + s);
const c6: Rgb = blend(['white', 'rgba(0, 0, 0, 0.5)'], 'darken');
const c7: Jab = blend(['white', 'rgba(0, 0, 0, 0.5)'], 'darken', 'jab');
7 changes: 7 additions & 0 deletions check-dts/common.errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { TakeColorChannels } from '../src/common';

// THROWS Property 'l' is missing in type '{ h: number; s: number; }' but required in type 'TakeColorChannels<"hsl">'.
const hsl1: TakeColorChannels<'hsl'> = { h: 30, s: 0.5 };

// THROWS Property 's' is missing in type '{ l: number; }' but required in type 'TakeColorChannels<"hsl">'.
const hsl2: TakeColorChannels<'hsl'> = { l: 1 };
6 changes: 6 additions & 0 deletions check-dts/common.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { TakeColorChannels } from '../src/common';

const okhsl1: TakeColorChannels<'okhsl'> = { h: 30, s: 0.5, l: 1, alpha: 0.25 };
const okhsl2: TakeColorChannels<'okhsl'> = { h: 30, s: 0.5, l: 1 };
const okhsl3: TakeColorChannels<'okhsl'> = { s: 0.5, l: 1 };
const hsl1: TakeColorChannels<'hsl'> = { s: 0.5, l: 1 };
4 changes: 4 additions & 0 deletions check-dts/convertLrgbToRgb.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { convertLrgbToRgb, Rgb } from '../src';

const r = convertLrgbToRgb({ r: 1, g: 1, b: 1 });
const c: Rgb = r;
8 changes: 8 additions & 0 deletions check-dts/converter.errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import converter from '../src/converter';
import type { Rgb } from '../src/rgb/types';

// THROWS Type 'Rgb | undefined' is not assignable to type 'Rgb'.
const case_1_expect_error: Rgb = converter()('#f0f0f0');

// THROWS Type 'Lab | undefined' is not assignable to type 'Rgb'.
const case_3_expect_error: Rgb = converter('lab')('#f0f0f0');
11 changes: 11 additions & 0 deletions check-dts/converter.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import converter from '../src/converter';
import type { Lab } from '../src/lab/types';
import type { Rgb } from '../src/rgb/types';
import type { Color, Oklab } from '../src';

const case_0_expect_success: Rgb | undefined = converter()('#f0f0f0');

const case_2_expect_success: Lab | undefined = converter('lab')('#f0f0f0');

declare const c: Color;
const case_3_expect_success: Oklab = converter('oklab')(c);
10 changes: 10 additions & 0 deletions check-dts/filters.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { filterBrightness } from '../src/filter';
import type { Hsl } from '../src/hsl/types';

const case_1_expect_success: Hsl = filterBrightness(1)({
mode: 'hsl',
h: 60,
s: 1,
l: 0.5,
alpha: 0.25
});
21 changes: 21 additions & 0 deletions check-dts/formatter.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Color, formatCss, formatRgb, modeP3, P3, Rgb, useMode } from '../fn';

declare const color: Rgb;
const str: string = formatRgb(color);

let p3 = useMode(modeP3);

declare const color2: Color;
const r2 = p3(color2);
const str2 = formatCss(r2);

declare const color3: string;
const r3 = p3(color3);
const tr3 = r3 === undefined ? formatCss(r3) : formatCss(r3);

declare const color4: string;
const r4 = p3(color4);
const tr4 = formatCss(r4);

declare const color5: Color;
const r5: string = formatRgb(color);
66 changes: 66 additions & 0 deletions check-dts/map.errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { mapper } from '../src/map';
import type { Rgb } from '../src/rgb/types';
import type { Hsl } from '../src/hsl/types';
import type { Okhsv } from '../src/okhsv/types';

const doubler = mapper(v => {
return v * 2;
});

// THROWS Type 'Rgb' is missing the following properties from type 'Hsl': s, l
const case_3_expect_error: Hsl = doubler({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ai I added tests for .d.ts files.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use this typing test system in all my open source.

For instance, in PostCSS https://github.com/postcss/postcss/blob/main/test/errors.ts

mode: 'hsl',
h: 0,
s: 0,
l: 0
});

// THROWS Type 'Rgb | undefined' is not assignable to type 'Hsl | undefined'
const case_5_expect_error: Hsl | undefined = doubler('hsl(0, 100%, 50%)');

const increaser = mapper(v => v + 10, null);

// THROWS Type 'Color | undefined' is not assignable to type 'Okhsv | undefined'
const case_6_expect_error: Okhsv | undefined = increaser(
'color(--okhsv 29.2338851923426 0.9995219692256307 0.9999999999999997)'
);

const decreaser = mapper(v => v - 10, undefined);

// THROWS Type 'Rgb | undefined' is not assignable to type 'Okhsv | undefined'
const case_9_expect_error: Okhsv | undefined = decreaser(
'color(--okhsv 29.2338851923426 0.9995219692256307 0.9999999999999997)'
);

// THROWS Type 'Rgb' is not assignable to type 'Hsl'
const case_10_expect_error: Hsl = decreaser({
mode: 'hsl',
h: 1,
s: 1,
l: 1
});

const tripler = mapper(v => {
return v * 3;
}, 'hsl');

// THROWS Type 'Hsl | undefined' is not assignable to type 'Hsl'
const case_13_expect_error: Hsl = tripler('hsla(240, 100%, 50%, 50%)');

// THROWS Type 'Rgb | undefined' is not assignable to type 'Rgb'
const case_8_1_expect_error: Rgb = decreaser(
'color(--okhsv 29.2338851923426 0.9995219692256307 0.9999999999999997)'
);

const oner = mapper(
(_v, _ch, conv_color, mode) => {
// THROWS Type 'Rgb' is not assignable to type 'Hsl'
const check_1_expect_error: Hsl = conv_color;

// THROWS Type '"rgb"' is not assignable to type '"hsl"'
const check_3_expect_error: 'hsl' = mode;
return 1;
},
undefined,
true
);
66 changes: 66 additions & 0 deletions check-dts/map.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { mapper } from '../src/map';
import type { Rgb } from '../src/rgb/types';
import type { Hsl } from '../src/hsl/types';
import type { Color } from '../src/common';

const doubler = mapper(v => {
return v * 2;
});

const case_1_expect_success: Rgb = doubler({
mode: 'rgb',
r: 0,
b: 0,
g: 0
});

const case_2_expect_success: Rgb = doubler({
mode: 'hsl',
h: 0,
s: 0,
l: 0
});

const case_4_expect_success: Rgb | undefined = doubler('hsl(0, 100%, 50%)');

const increaser = mapper(v => v + 10, null);

const case_5_expect_success: Color | undefined = increaser(
'color(--okhsv 29.2338851923426 0.9995219692256307 0.9999999999999997)'
);

const case_7_expect_success: Hsl = increaser({
mode: 'hsl',
h: 0,
s: 0,
l: 0
});

const decreaser = mapper(v => v - 10, undefined);

const case_8_expect_success: Rgb | undefined = decreaser(
'color(--okhsv 29.2338851923426 0.9995219692256307 0.9999999999999997)'
);

const tripler = mapper(v => {
return v * 3;
}, 'hsl');

const case_11_expect_success: Hsl | undefined = tripler('#3690');
const case_12_expect_success: Hsl = tripler({
h: 240,
s: 1,
l: 0.5,
mode: 'hsl',
alpha: 0.5
});

const oner = mapper(
(_v, _ch, conv_color, mode) => {
const check_0_expect_success: Rgb = conv_color;
const check_2_expect_success: 'rgb' = mode;
return 1;
},
undefined,
true
);
5 changes: 5 additions & 0 deletions check-dts/modes.errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { converters } from '../src/modes';
import type { Cubehelix, Rgb } from '../src';

// THROWS Type '((c: Omit<Cubehelix, "mode">) => Rgb) | undefined' is not assignable to type '(c: Omit<Cubehelix, "mode">) => Rgb'
const c1: (c: Omit<Cubehelix, 'mode'>) => Rgb = converters.cubehelix.rgb;
5 changes: 5 additions & 0 deletions check-dts/modes.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { converters } from '../src/modes';
import type { Cubehelix, Rgb } from '../src';

const c1: ((c: Omit<Cubehelix, 'mode'>) => Rgb) | undefined =
converters.cubehelix.rgb;
3 changes: 3 additions & 0 deletions check-dts/named.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { colorsNamed } from '../fn';

const s: 0xa0522d = colorsNamed.sienna;
31 changes: 31 additions & 0 deletions check-dts/random.errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import random from '../src/random';
import type { Rgb } from '../src/rgb/types';
import type { Yiq } from '../src/yiq/types';
import type { Hsl } from '../src/hsl/types';

// THROWS No overload matches this call
const c1 = random('1');

// THROWS Type 'Rgb' is not assignable to type 'Hsl'
const c2: Hsl = random();

// THROWS Type 'Hsi' is missing the following properties from type 'Rgb': r, g, b
const c3: Rgb = random('hsi');

// THROWS No overload matches this call
const c4: Yiq = random('yiq', {
r: [1, 2]
});

// THROWS No overload matches this call
const c5: Yiq = random('yiq', {
y: []
});

// THROWS No overload matches this call
const c6: Yiq = random('yiq', {
y: [1]
});

// THROWS No overload matches this call
const c7 = random(undefined, { h: [0, 1] });
27 changes: 27 additions & 0 deletions check-dts/random.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import random from '../src/random';
import type { Rgb } from '../src/rgb/types';
import type { Yiq } from '../src/yiq/types';

const c1 = random();

const c2: Rgb = random();

const c3: Rgb = random('rgb');

const c4: Yiq = random('yiq');

const c5: Yiq = random('yiq', {
y: 1
});

const c6: Yiq = random('yiq', {
y: [0, 1]
});

const c7 = random(undefined, {
r: 1
});

const c8 = random(undefined, {
r: [0, 1]
});
1 change: 1 addition & 0 deletions docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ These projects add more functionality to Culori, but they're separate as to keep

- [Moqups](https://moqups.com) — all our color-manipulation functions are handled by Culori.
- [Schemist](https://github.com/felixgirault/schemist) — color schemes builder backed by Culori.
- [OKLCH & LCH Color Picker](https://github.com/evilmartians/oklch-picker) — color picker and converter for Oklab and Lab color space backed by Culori.
- [Color Name API](https://github.com/meodai/color-name-api) — a REST API for color names that makes use Culori's [differenceCiede2000](https://culorijs.org/api/#differenceCiede2000) to return a fitting name for every color.

Does your product/project use Culori? Create a PR and add yourself to this list.
Expand Down
6 changes: 6 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Execute following command

```shell
cd ./example
npx ts-node --esm main.ts
```
Loading