-
Notifications
You must be signed in to change notification settings - Fork 30
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
Closed
Add type definitions #166
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 25494d7
Add types for random function
bijela-gora 93956fa
Fix hsl shape
bijela-gora 68d4e1f
Add types for displayable
bijela-gora 4be690f
Fix typo
bijela-gora d3be690
Improve readability
bijela-gora 8a0f9e2
Add types for round function
bijela-gora 8c3434c
Add kind of tests for types
bijela-gora cf1e7e5
Add types for blend function
bijela-gora 244a90d
More accurate type for type parameter ob blend function
bijela-gora df783d5
Add types for 'average' function
bijela-gora 6702c35
More accurate type for 'random' function
bijela-gora 8491152
Add types for lab color
bijela-gora 73d2e09
Add types for 'converter' function
bijela-gora c78363d
Add some types
bijela-gora 580a80e
Add types for a98 colors
bijela-gora 67f3c28
Add types for cubehelix color
bijela-gora c5ac822
Add types for dlab color
bijela-gora 6710f4a
Add more types
bijela-gora 9150ec2
Add types for fixup functions
bijela-gora 086934b
Add types for hsi color
bijela-gora 4295553
Add some types
bijela-gora 5d68735
Add types for hsv
bijela-gora 9adf04f
Add types for hwb color
bijela-gora ac770b6
Add types for luv color
bijela-gora 15104df
Add types for lchuv color
bijela-gora fe7198b
Add types for lch and lch65
bijela-gora 5d85485
Add function for easing functions
bijela-gora 0fb67d8
Add function for 'samples' functions
bijela-gora 41f36c3
Update types
bijela-gora 1c5bff8
Add types for jab color
bijela-gora 2ea3ee5
Add types for jhc color Bijela Gora
bijela-gora e40338a
Fix types for Lch65
bijela-gora e7568f6
Add types to Color union
bijela-gora 1945859
Add okhsl color types definition
bijela-gora 81d7dd1
Add types for yiq color
bijela-gora ec44325
Add more types
bijela-gora 9962141
Add more types
bijela-gora df8ee6f
Add more types
bijela-gora be75aad
Add index.d.ts
bijela-gora 57f8b84
Fix a98 type
bijela-gora 3c0cfe8
Fix hwb type
bijela-gora 9b3cffc
Fix okhsv type
bijela-gora 8c14105
Fix yiq type
bijela-gora ab72c6e
Add types for 'clamp' functions
bijela-gora 6df7e4b
Add types for 'deficiency' functions
bijela-gora 7507afb
Add types for 'map' and 'filter' functions
bijela-gora 74b100b
Add types for wcag file
bijela-gora a2f5330
Add more types
bijela-gora b6bc11e
Add more types
bijela-gora 8bba16c
Add more types
bijela-gora 74647a9
Add types for parseTransparent function
bijela-gora 772daba
Add more types
bijela-gora e2e164d
Fix types for 'interpolate' functions
bijela-gora e666a33
Remove todo comment
bijela-gora cafefed
Update types for 'prepare' function
bijela-gora 7b80b3e
Minor change
bijela-gora cf90336
Delete dead code
bijela-gora f53dbef
Remove comments in tsconfig.json
bijela-gora 9718f24
Remove unnecessary step
bijela-gora f738467
Simplify color space types
bijela-gora 4905e73
Update for index-fn.js
bijela-gora a73ae10
Improve type definition for 'random' function
bijela-gora 5a52ee9
Improve types for 'blend' function
bijela-gora 99a274d
Improve types for 'average' function
bijela-gora f4ff70d
Improve 'converter' function type
bijela-gora ec1c638
Fix an issue when color is string and mode is null
bijela-gora 183aa2e
Remove leftovers
bijela-gora ddb2e88
Improve mapper function type
bijela-gora cad56c8
Add tests for type definition of 'random' function
bijela-gora fcc390d
Improve script a little bit
bijela-gora b343ca8
Add tests for blend function
bijela-gora 945254d
Improve types for 'average' function
bijela-gora 58ab198
Fix types for 'blend' function
bijela-gora 08eaa54
Improve 'converter' function type
bijela-gora 6223f17
Update type checks for mapper function
bijela-gora 0b5135a
Add tests for prepare function
bijela-gora c77099a
Simplify types for clamp functions
bijela-gora a53d67c
Remove file in which I checked type definitions
bijela-gora 8d67c64
Remove unused import
bijela-gora c7217f7
First file moved from snapshot testing to check-dts
bijela-gora 80475d3
Second file moved from snapshot testing to check-dts
bijela-gora feae995
Move third file from snapshot testing to check-dts
bijela-gora a692233
Move 4th file from snapshot testing to check-dts
bijela-gora 8e4b5dd
Remove unused imports
bijela-gora 5d09757
Migrate what is left from snapshot testing to check-dts
bijela-gora f3c1da0
Remove comments
bijela-gora e738a8f
Remove unnecessary dependencies
bijela-gora 5a6c73e
Add example
bijela-gora 3b909f9
Remove prepare script because I see it in logs
bijela-gora 521d221
Fix config and some types
bijela-gora 03bcf5f
Add fn.d.ts file to allow to import with 'culori/fn'
bijela-gora ae876b9
Remove check-dts command run because it is not stable
bijela-gora 8c14058
Add todo comment
bijela-gora e697e34
Add fn.d.ts to files which should be published
bijela-gora beac4cc
Remove unused type
bijela-gora c9c4fe8
Export useful input types
bijela-gora cfe074a
Add some definitions
bijela-gora 3f4edd6
Add one more definition
bijela-gora d513433
Check-dts does not support "extends" property of tsconfig
bijela-gora 605efb7
Temp commit to show the issue
bijela-gora 35c3439
Revert "Temp commit to show the issue"
bijela-gora 5860ac2
Fix config
bijela-gora 8083505
Reduce noise
bijela-gora 4643b3b
Add one more check
bijela-gora 6f37434
Add one more definition.d.ts
bijela-gora ce72687
Add one more definition.d.ts
bijela-gora fd7cca9
Replace 'import type' with 'import'
bijela-gora 7f13323
Add one more definition.d.ts
bijela-gora dc317d7
Add one more definition.d.ts
bijela-gora da59914
Add one more definition.d.ts
bijela-gora 58c9c49
Add one more definition.d.ts
bijela-gora f2d5f77
Add one more definition.d.ts
bijela-gora f9ca781
Fix definition types
bijela-gora a5af4b3
Add one more definition.d.ts
bijela-gora 7ca7c29
Add one more definition.d.ts
bijela-gora 65fb8c9
Add one more definition.d.ts
bijela-gora 06ddb25
Add one more definition.d.ts
bijela-gora 6c4d8b1
Remove '.js' in imports in .d.ts files
bijela-gora 400938d
Remove unused types
bijela-gora 220c8cb
Add one more definition.d.ts
bijela-gora 64a642f
More accurate type of 'convertLabToLch' function
bijela-gora 5343d02
More accurate type of 'convertLrgbToRgb' function
bijela-gora cb675e9
Add test for convertLrgbToRgb function type
bijela-gora 1bd15ee
Add one more definition.d.ts
bijela-gora 6e4e6e8
Add one more definition.d.ts
bijela-gora 3ee48da
Add one more definition.d.ts
bijela-gora 0d96334
Remove '.js' in imports in .d.ts files
bijela-gora adc89c6
Replace 'import type' with import in .d.ts files
bijela-gora dbcd0bd
Add types for modes.js
bijela-gora 53804f1
More accurate type def for converter factory
bijela-gora c9a4fda
Increasing the accuracy of formatter types
bijela-gora b76810c
Increase the accuracy of formatters types
bijela-gora 49417eb
Add types for named colors
bijela-gora 3714acf
Fix formatters types
bijela-gora 3370d4c
Small update
bijela-gora 86bc62f
Change an order of types
bijela-gora 86319c2
Make the ConvertFn type a little more convenient
bijela-gora e1303d8
Add .idea/ to gitignore
bijela-gora 5f8fa2d
All 'h' channels can be not assigned
bijela-gora d810061
Add OKLCH & LCH Color Picker to the list of products using Culori
bijela-gora 5cfb5f9
Fix copy&paste typo
bijela-gora effad4b
Fix type tests
bijela-gora d44cd8b
Remove unused import statements
bijela-gora 7c13fef
Add two tests
bijela-gora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.sublime-workspace | ||
.idea/ | ||
.DS_Store | ||
build/ | ||
bundled/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ | ||
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 | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { colorsNamed } from '../fn'; | ||
|
||
const s: 0xa0522d = colorsNamed.sienna; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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