---
title: Template literal types build string unions from existing types
slug: typescript-template-literal-types
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source: https://iinventedlight.com/library/notes/typescript-template-literal-types.md
source_license: CC-BY-4.0
attribution: Original synthesis by iinventedlight, drafted by Librarian with AI assistance; based on the attributed sources
  below.
author: Librarian
client: Librarian
date: '2026-11-05'
checked_on: '2026-11-05'
as_of: '2026-11-05'
status: published
confidence: medium
category: coding-references
tags:
- typescript
- template
- literal
untested: Reference note. No code or commands were run to validate behavior.
sources:
- id: S1
  title: Template literal types
  publisher: Microsoft and TypeScript documentation contributors
  url: https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html
  accessed: '2026-11-05'
  license: CC-BY-4.0
  license_url: https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE
  license_verified: '2026-11-05'
  green: true
  attribution: Microsoft and TypeScript documentation contributors; Template literal types; CC-BY-4.0
  snapshot: _fetched/ts-template.txt
- id: S2
  title: Everyday types
  publisher: Microsoft and TypeScript documentation contributors
  url: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html
  accessed: '2026-11-05'
  license: CC-BY-4.0
  license_url: https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE
  license_verified: '2026-11-05'
  green: true
  attribution: Microsoft and TypeScript documentation contributors; Everyday types; CC-BY-4.0
  snapshot: _fetched/ts-types.txt
---
# Template literal types build string unions from existing types

## Summary
Template literal types use template-string syntax in a type position. They combine string literal types and can expand unions into sets of permitted strings. [S1]

## Details
A union in an interpolated position contributes each of its members. Multiple interpolated unions combine across positions, so the result can grow quickly. The Handbook recommends generating large string unions ahead of time. Literal unions remain useful for a bounded vocabulary, such as a small set of accepted argument values. These types describe strings; they do not generate runtime strings. [S1, S2]

## Claims
- id: C1
  claim: "Template literals use template-string syntax at the type level."
  source: S1
  evidence: "but are used in type positions"
- id: C2
  claim: "Unions combine across interpolated positions."
  source: S1
  evidence: "the unions are cross multiplied"
- id: C3
  claim: "Literal unions can restrict a function to known argument values."
  source: S2
  evidence: "functions that only accept a certain set of known values"

## Sources
- [S1] Template literal types. Microsoft and TypeScript documentation contributors. https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html. CC-BY-4.0; license: https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE. Accessed 2026-11-05.
- [S2] Everyday types. Microsoft and TypeScript documentation contributors. https://www.typescriptlang.org/docs/handbook/2/everyday-types.html. CC-BY-4.0; license: https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE. Accessed 2026-11-05.

## Attribution and notices
This note is CC BY 4.0. Source material has been condensed and restated; short evidence excerpts retain their source license.

TypeScript Website documentation is CC BY 4.0. This is an original condensed explanation, not the original documentation.
