-
Notifications
You must be signed in to change notification settings - Fork 46
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
Question: How to type "a color"? #58
Comments
You can define a Color type as a key of the package object import pc from "picocolors";
type Color = keyof typeof pc;
const DEFAULT_COLORS: [Color, Color, Color] = ["white", "yellow", "red"]; |
Thanks for your reply! This expression is not callable.
Not all constituents of type 'boolean | Formatter | ((enabled?: boolean) => Colors)' are callable.
Type 'false' has no call signatures.typescript(2349)
const DEFAULT_COLORS: [keyof Colors | "createColors", keyof Colors | "createColors", keyof Colors | "createColors"] Update the sandbox: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is just running fine:
https://codesandbox.io/p/sandbox/picocolors-types-29zfg9?file=%2Fsrc%2Findex.ts%3A11%2C1
But how to type this correct? I'm too stupid, sorry.
For
DEFAULT_COLORS[1]
I get this:
Problem is that a user can just overwrite colors by using own colors handed in as strings. So I'm trying to stick to that.
The text was updated successfully, but these errors were encountered: