I'm using an intermediary step for creating a type that has property keys that must be the same as the keys of a specified interface
// 1. Create Interface
interface IDetail {
name: string;
enabled: boolean;
}
// 2. Create a 'type' that has properties that match the properties of an interface
type DetailType = {
[key in keyof IDetail]: any
}
// 3. Apply the type to an object literal
const control: DetailType = {
name: [],
enabled: []
}
I repeat this pattern quite often, and I'm wondering is there a way to generalize the 2nd step - possibly using generics?
anyyou lose type information..Record<keyof Interface, any>a thing you need?