Having an object for theme's colors:
themeColors = {
primary: ['#fff', '#000'],
secondary: ['#DDD', '#333'],
error: ['#CCC', '#444']
}
We can assign type like this:
themeColor: Record<string, [string; string]>
How to add restriction first and second of tupel should be unique? I mean
themeColors = {
primary: ['#fff', '#000'],
secondary: ['#fff', '#333'],
}
or
themeColors = {
primary: ['#fff', '#000'],
secondary: ['#DDD', '#000']
}
shouldn't pass type checking, becouse have duplication ('#fff' in first case, '#000' in second case)
I belive it sould be close to this approach
Is there a way to define type for array with unique items in typescript?