if (c.type === 'a') { /* c is of type A here */ }
This is dynamic typing, this code is checked at runtime, and it's leveraged statically.
const c: C = Math.random() < 0.5 ? { type: 'a' } : { type: 'b' }.