Skip to content
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

Range function definition returns a number instead of a Color #298

Closed
nsilvestri opened this issue Apr 10, 2023 · 1 comment · Fixed by #299
Closed

Range function definition returns a number instead of a Color #298

nsilvestri opened this issue Apr 10, 2023 · 1 comment · Fixed by #299
Labels
bug Something isn't working

Comments

@nsilvestri
Copy link
Contributor

I'm trying to use Color.range(color2) to interpolate between two colors. However, TypeScript is complaining that the function returned from range() returns a number instead of a Color. The documentation states that this function returns a Color, and in runtime, the object is indeed a Color.

Looking at the TypeScript definition, it seems that this function is defined to return a number:

export type Range = ((percentage: number) => number) & {
    rangeArgs: { colors: [Color, Color]; options: Record<string, any> };
};

Do I misunderstand the API, or is there a mistake in the TypeScript definition?

@LeaVerou
Copy link
Member

It looks like there's a mistake in the TS definition, thank you for spotting that! Do you want to submit a PR to fix it? 😁

@LeaVerou LeaVerou added the bug Something isn't working label Apr 10, 2023
LeaVerou pushed a commit that referenced this issue Apr 10, 2023
The function represented by Range should return a Color, not a
number.

Fixes #298.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants