Closed
Description
Bug Report
π Search Terms
bug extends number bigint
π Version & Regression Information
- This was reported in support generic type when checking implicit conversion of symbol to stringΒ #44578 and occurs in playground on v4.74 and v4.8.0-beta
β― 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.