You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the files for the constants like "amber" are simply declare const amber: { 50: ..., ...etc }. This means they don't have an actual common type I can pass into a function or get back from a function. It would be great if there was an interface for the object to make it easier to make such declarations (just doing "typeof amber" doesn't auto-apply to the other constants like blue). Something like
Trying to make a color picker type of thing, passing in the constants with keys and getting the full values back from the selector object. Until I added the above interface, I was forced to things which I'd prefer to avoid.
The text was updated successfully, but these errors were encountered:
Updated the key - it'll take both string and number to support amber[500] as well as amber['500']. amber[500] === amber['500'] returned true as expected/hoped.
mbrookes
changed the title
add interface for color constants (amber, etc...)
[colors] Add TypeScript interface for color constants
Dec 26, 2021
Duplicates
Latest version
Summary 馃挕
Currently the files for the constants like "amber" are simply
declare const amber: { 50: ..., ...etc }
. This means they don't have an actual common type I can pass into a function or get back from a function. It would be great if there was an interface for the object to make it easier to make such declarations (just doing "typeof amber" doesn't auto-apply to the other constants like blue). Something likeExamples 馃寛
No response
Motivation 馃敠
Trying to make a color picker type of thing, passing in the constants with keys and getting the full values back from the selector object. Until I added the above interface, I was forced to things which I'd prefer to avoid.
The text was updated successfully, but these errors were encountered: