• Error
  • Reported by the tsconfig loader
  • Reported by the lexer and parser

TS1002

Unterminated string literal.

A string literal has no closing quote before the end of the line. Add the missing quote, or use a template literal for multi-line text.

What it means

A string written with ' or " must end on the same line it starts on. The parser reached the end of the line (or the file) without finding the closing quote. The rest of the line is read as part of the string, so other errors often follow on the next lines.

Example

index.ts
const greeting = "hello;
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,25): error TS1002: Unterminated string literal.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Add the closing quote that matches the opening one.
  • For text that spans lines, use a template literal (`...`) or join strings with +.
  • A backslash before the quote (\") escapes it; remove the backslash if the quote is meant to end the string.