I have an object defined with string keys and number values:
class MyService {
private static readonly MAPPING: { [ index: string ]: number } = {
a: 16,
b: 32,
};
}
And I would like to have another object that only allows the values (numbers) defined in that mapping as keys
class MyService {
private static readonly MAPPING: { [ index: string ]: number } = {
a: 16,
b: 32,
} as const;
public static states: { [ index in ?!? (Object.values(MyService.MAPPING)) ?!? ]: boolean } = {}; // <-- clearly this is wrong
}
So that:
MyService.states[16] = true would be valid, but MyService.states[17] = true would not.
How can I accomplish this?