support generic type when checking implicit conversion of symbol to string by Zzzen · Pull Request #44578 · microsoft/TypeScript (original) (raw)

When fixing this bug, I find bigint has the same problem.

type numberOrBigint = number | bigint;

function getKey(key: numberOrBigint) { +key; // ✔ should error, and the compiler does 0 + key; // ✔ should error, and the compiler does }

function getKey2(key: S) { +key; // ❌ should error , but the compiler does not 0 + key; // ✔ should error, and the compiler does }