Avatar ·

How to do string interpolation in TypeScript? Template strings

Hello everyone! I just started learning TypeScript after JavaScript and ran into a problem. I need to combine several variables into one string to output a message to the user.\n\nIn JavaScript I usually did this:\n\n```typescript\nlet name = "Alexey";\nlet age = 25;\nlet message = "Hello, my name is " + name + " and I am " + age + " years old.";\nconsole.log(message);\n```\n\nBut this looks cumbersome, especially when there are many variables. I heard that ES6 introduced template strings with backticks and ${}, but I'm not sure if they work in TypeScript. When I try to write:\n\n```typescript\nlet message = `Hello, my name is ${name} and I am ${age} years old.`;\n```\n\nDoes TypeScript throw an error or not? Do I need to configure anything additional in tsconfig.json? And can I perform inside the interpolation