Template Literal Type

A template literal type is a combination of Template literal and string literal type. It is capable of resolving string interpolations within a template string to use it for strong typing:

1
2
3
4
5
type Action = 'click';

type ClickEvent = `${Action}Event`;

const myEvent: ClickEvent = 'clickEvent';