How to perform string interpolation in TypeScript?

C# uses string interpolation

int value = 100;
Console.WriteLine($"The size is {value}.");

Output:

The size is 100.

How to do the same thing in TypeScript?


Solution 1:

In JavaScript you can use template literals:

let value = 100;
console.log(`The size is ${ value }`);

Solution 2:

Just use special `

var lyrics = 'Never gonna give you up';
var html = `<div>${lyrics}</div>`;

You can see more examples here.