TS1355
A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
Broken Code ❌
const result = (Math.random() < 0.5 ? 0 : 1) as const;Fixed Code ✔️
You cannot apply a const assertion to the result of a ternary operator. It is necessary to restrict the usage of const assertions to the individual literal expressions:
const result = Math.random() < 0.5 ? (0 as const) : (1 as const);