Re:TypeScript 3.7
by seanwilson on Tuesday November 05, 2019 @05:52PM
(#21457653)
Thanks, you can still trick it with this though (there's no type error):
const x = [1, 2] as const;
const r = 666 + 1;
const y = x[r];
const z = y + 3;
Using `as const` will report both the 2nd and 3rd lines as type errors. You've been able to do this in TypeScript for a while even before they introduced the `as const` syntax.