I\'m trying to use the following pattern:
enum Option {
ONE = \'one\',
TWO = \'two\',
THREE = \'three\'
}
interface OptionRequirement {
someBool: bo
In my case I needed the properties to be optional, so I created this generic type.
type PartialRecord = { [P in K]?: T; };
Then use it as such:
type MyTypes = 'TYPE_A' | 'TYPE_B' | 'TYPE_C';
interface IContent {
name: string;
age: number;
}
interface IExample {
type: string;
partials: PartialRecord;
}
Example
const example : IExample = {
type: 'some-type',
partials: {
TYPE_A : {
name: 'name',
age: 30
},
TYPE_C : {
name: 'another name',
age: 50
}
}
}