The following piece of code does exactly what I intend to know with one caveat, I would like to avoid having to explicit the generic it needs.
type EventGroup = {
actions: "run" | "save"
other: "bla"
}
export type EventType<T extends keyof EventGroup> = `${T}/${EventGroup[T]}`
const t: EventType<"actions"> = "actions/run"
I would like Typescript to infer that:
`actions/run` -> valid
`actions/save` -> valid
`actions/bla` -> NOT valid
`other/bla` -> valid
Which is what this code does but with an explicit generic.