How to make Typescript interface property to be depended on another property

Consider an example:

type Colors = {
  light: 'EC3333' | 'E91515'
  dark: '#100F0F' | '140F0F' 
}

interface Palette {
  colorType: keyof Colors
  color: Colors[keyof Colors]
}

is there any way that type of the color property becomes depended on colorType property?

meaning - when I choose colorType light, color type should become 'EC3333' | 'E91515'



from Recent Questions - Stack Overflow https://ift.tt/3y6jGqZ
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept