Literal Types

A literal type allows only one value. A literal can be an exact number or an exact string instead of being any number or being any string:

1
2
3
4
5
6
7
8
9
10
const numberLiteral: 72 = 72;
const stringLiteral: "Benny" = "Benny";
const booleanLiteral: true = true;

enum ConnectionState {
OFF,
ON
}

const enumLiteral = ConnectionState.OFF;