I want to get a union of all the keys under states in this object type,
I have a nested object of state keys. I want to get a union of all these keys under state in dot notation.
For example, for this config:
type Config = {
initial: string;
states: {
idle: {
on: {
START: string;
};
};
running: {
on: {
PAUSE: string;
};
};
paused: {
initial: string;
states: {
frozen: {
on: {
HEAT: string;
};
};
};
on: {
RESET: string;
};
};
};
I want 'idle' | 'running' | 'paused' | 'paused.frozen'
Is this possible? Any ideas?
type KeyType = keyof Config.states | keyof Config.states.paused.states;although that doesn't generalize.states