Question · JavaScript and TypeScript course · Module 10: TypeScript in Practice

Template literal types

What does the type declaration type Greeting = Hello ${string} create in TypeScript?

Answer options

  • A type accepting any string starting with 'Hello '
  • Compilation error - templates do not work in types
  • A type accepting exactly the string 'Hello ${string}'
  • A type accepting only 'Hello'

You can check the correct answer by solving this task in the CodeWorlds game.