Covariance breaks when checking for undefinded
in a type
#55161
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Bug Report
I'm using the
solid-js
npm package which defines a type calledSetter
:I don't fully understand the reasoning behind it, but it's giving me some problems:
I created an object with the property
0
which contains aSetter
and it appears to not be covariant.Inspecting the error it looks like that the problem is originated from this part
undefined extends T ? () => undefined : {}
, infact if I remove it this works, moreover the problem would still occur if that was the only part of the type:I think it is an error because the types are the same:
Additionally if
Test
were to be defined as[ Setter<T> ]
the error would not occur:🔎 Search Terms
🕗 Version & Regression Information
This changed between versions 3.3.3 and 3.5.1. (The only playground version in which it doesn't occur is 3.3.3)
⏯ Playground Link
Playground Link
💻 Code
🙁 Actual behavior
Can't assign
b
with the value ofa
.It is wrong at the very least because it is not consistent
🙂 Expected behavior
Can assign
b
with the value ofa
The text was updated successfully, but these errors were encountered: