I have a piece of code that achieves my desired outcome, but I want to avoid explicitly specifying the generic it requires.
type EventGroup = {
actions: "run" | "save"
other: "bla"
}
export type EventType<T extends keyof EventGroup> = `${T}/${EventGroup[T]}`
const t: EventType<"actions"> = "actions/run"
I am hoping that Typescript can automatically infer the following:
`actions/run` -> valid
`actions/save` -> valid
`actions/bla` -> NOT valid
`other/bla` -> valid
The code currently accomplishes this, but I would like to eliminate the need for an explicit generic.