I had this error on a Typescript project, which was actually a beginners mistake.

How to fix errorTS1002

error TS1002: Unterminated string literal.


const text = 'Lorem ipsum dolor


You have to close the string literal with an ending ':

const text = 'Lorem ipsum dolor';

If you want to support multiline text, then you would have to use string concatenation:

The concat() is an inbuilt function in TypeScript which is used to add two or more strings and returns a new single string. 


string.concat(string2, string3[, ..., stringN]);
const text = 'Lorem ipsum dolor, ' +
  'sed diam nonumy eirmod tempor.';

Another solution would be using a template literal:

const text = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, 
  sed diam nonumy eirmod tempor .`;


Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!