Literal types
A literal type is one exact value used as a type: "left" means only the text "left". Joined with |, the type Align allows exactly three strings: "left", "right", "center". Nothing else.
Line 2 makes a variable a of type Align and gives it "left". tsc compares the value with the allowed list. "left" is one of them, so the line passes.
Line 3 sets a to "centre", the British spelling. To a person it looks fine, but it matches no slot, so tsc reports error TS2820 on line 3 and even suggests "center".
You change it to "center". Now the value matches the third slot exactly, and tsc finds no errors. The type caught a typo a plain string type would have let through.
let and const
Without a type, let a = "left" gets type string, because a let may change later. A const can never change, so const c = "left" gets the literal type "left". Line 2 writes : Align to allow exactly three.
Enums
Line 4 is an enum: a named set of constants. Dir has four members, Up, Down, Left, Right. You write Dir.Left instead of a bare number, so the code says what it means.
No member has a value written, so TypeScript numbers them: the first is 0 and each next member is the one before plus 1. Up is 0, Down 1, Left 2, Right 3.
At run time
tsc writes align.js. Line 1, the type Align, vanishes: types are erased. The enum does not. It becomes a real JavaScript object, filled in both directions: name to number and number to name.
Line 5 runs. Dir.Left looks up the name and gives 2. Dir[2] looks up the number and gives "Left": a reverse mapping. console.log prints both: 2 Left.
What happens
;; step 1/9 · literal > 1 type Align = "left" | "right" | "center"; "left" a literal type: one exact string | "or": a union of types Align = "left" | "right" | "center" string would allow any text at all
The "Did you mean" part (error TS2820) is what tsc 5.9 adds when an allowed value is spelled almost the same. With no close match the error is TS2322 without the suggestion. The align.js shown is what tsc 5.9 writes with no settings; its default target writes let as var. Other targets change small details, not the enum object.