Skip to main content
Version: 2.8.y

String Manipulation

It is important to understand how Typescript string literal works in order for Typescript to infer the literal type properly.

const a = 'a'
const b = 'b'

const ab = a + b
// ^?

const ab1 = `${a}${b}`
// ^?
how to concate string safely

playground

Do not use + to concate the string because + output wide string type. Always use template string to concate string for literal types.