A literal type is a more specific sub-type of a collective type. A literal type can represent an exact value, such as a specific number or string, instead of a general value that can be any number or string.
Narrowing refers to the process of reducing the set of possible values that a variable can hold. TypeScript applies literal narrowing, when declaring a variable with the
On the other hand, when using the
let keyword, TypeScript will infer a collective type such as
number for the variable: