How to create an interface to type check an object based on the keys entered in another object.
For example:
const myObject = {
colors: {
black: '#000',
white: '#fff'
},
palette: {
primary: 'black',
secondary: 'orange' // <- should give an error because orange does not exist in colors object
}
};
asMyObject()helper function to infer the generic type. Does that meet your needs? If so I can write up an answer; if not, please let me know what I'm missing about your use cases.