the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

Editing TS1002:

All diagnostics and fixes are authored in markdown. Propose any changes by editing the markdown. Additional fixes can be added. A preview of the rendered diagnostic will update when changes are made.

Once all proposed changes are made, the Propose button will submit the information and confirm raising the PR.

TS1002

Unterminated string literal.

Occurs when there is an unterminated string literal somewhere. String literals must be enclosed by single (') or double (") quotes.

Often, it caused by an attempt to use a string literal over multiple lines:

const str = "Here is some text
  that I want to break
  across multiple lines.";

Fix: Multiple Lines

If you are trying to break a string across multiple lines, you can use template literals using the backtick (`) instead:

const str = `Here is some text
  that I want to break
  across multiple lines.`;

Or you can use string concatenation:

const str = "Here is some text" +
  "that I want to break " +
  "across multiple lines.";

Or you can use a backslash (\) at the end of the line:

const str = "Here is some text \
  that I want to break \
  across multiple lines.";