Is there a way to restrict the keys of an object so that they must match those declared in an array of a union type?
type Category = 'software' | 'hardware' | 'books'
type Item = {
categories: Category[];
registry: Partial<{[key in Category]: string}>
}
//This code should result in an error because 'books' is not included in the categories array:
const myInValidItem: Item = {
categories: ['software', 'hardware'],
registry: { books: 'blabla' }
}