Some types depend on the shape of another type. A helper can extract an array element type, or extract the payload from the successful branch of a result union. Conditional types express that choice, and infer names the type you want to recover. Template literal types build a limited vocabulary from smaller string unions.
The runtime boundary still needs validation. A string from JSON is not a valid event merely because a type lists four event names. Check the complete string before narrowing it. You will also use a literal object as an alternative to an enum: it supplies runtime values and a derived union without maintaining two separate lists. Hidden checks include inherited object keys and strings that contain a valid name inside an invalid one.
Enums. Numeric enums emit both name-to-number and number-to-name mappings. An explicit first value controls later auto-incremented values. String enums emit named string values without reverse mappings. Use the enum member at a typed boundary; use an as const object when a literal-value union suits the API.