Answer the question
In order to leave comments, you need to log in
How to make an object's dynamic key based on the values of another object?
Good day.
There is an object that is a map of aliases and possible values.
const TYPES = {
TYPE: 'type',
ANOTHER_TYPE: 'anotherType',
}
const object = {
type: () => {},
anotherType: () => {},
}
Answer the question
In order to leave comments, you need to log in
interface Types {
TYPE: 'type';
ANOTHER_TYPE: 'anotherType';
}
type SomeType = {
[P in Types[keyof Types]]: () => void;
};
const object: SomeType = {
type: () => {},
anotherType: () => {}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question