Q20. What are template literal types?

Template literal types combine string literal types into new string types, often forming event names, route labels, or property access patterns. They can distribute across unions to create combinations, but do not validate arbitrary runtime strings.

A type such as ${Field}Changed can derive event names from a union of field names.

Note

Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.

TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";
💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
  • Explain the concept in your own words.
  • Know the practical trade-off and its limits.
  • Use a small example to demonstrate the idea.
Knowledge Check

Are template literal types a runtime string transformation?