Bug Report
🔎 Search Terms
bug extends number bigint
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
Playground link with original code from #44578
💻 Code
type numberOrBigint = number | bigint;
function getKey(key: numberOrBigint) {
// @ts-expect-error ✔
+key;
// @ts-expect-error ✔
0 + key;
}
function getKey2<S extends numberOrBigint>(key: S) {
// @ts-expect-error ❌ should error, but the compiler does not
+key;
// @ts-expect-error ✔
0 + key;
}
🙁 Actual behavior
+key is not an error in getKey2.
🙂 Expected behavior
It should be an error to be consistent with getKey, as S could be numberOrBigint instead of a more specific type.
Bug Report
🔎 Search Terms
bug extends number bigint
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
Playground link with original code from #44578
💻 Code
🙁 Actual behavior
+keyis not an error ingetKey2.🙂 Expected behavior
It should be an error to be consistent with
getKey, asScould benumberOrBigintinstead of a more specific type.