You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I love TypeScript, I appreciate that you provide us a great development experience.
But I found a strange behavior. I think it's a bug because I remember it worked correctly two years ago.
I want to use never as a type parameter that expects a union type of values of tuple-like array, in order to express that nothing is specified.
So I tried to use conditional type to handle never like:
But it doesn't work correctly. If I set never to the parameter T, the result is always never, not PlaceholderType.
I understand I can use null or undefined instead. But actual values are stored in array and I don't want to use such values in the array. I mean, this issue happens when I assign [].
TypeScript Version: 3.9.2, (also 3.8.3)
Search Terms:
I tried searching whether a similar issue has already raised with these keywords is:issue never type parameter "extends never" conditional "<never>" .
Sorry, I didn't read the page. 🙇♂️ I'll be careful about it in next time.💪
I understand the reason. I agree that it should be resolved to never. 🙂
Also, it seems that the issue you linked helps me to solve my problem.
Thank you so much!
I love TypeScript, I appreciate that you provide us a great development experience.
But I found a strange behavior. I think it's a bug because I remember it worked correctly two years ago.
I want to use
never
as a type parameter that expects a union type of values of tuple-like array, in order to express that nothing is specified.So I tried to use conditional type to handle
never
like:But it doesn't work correctly. If I set
never
to the parameterT
, the result is alwaysnever
, notPlaceholderType
.I understand I can use
null
orundefined
instead. But actual values are stored in array and I don't want to use such values in the array. I mean, this issue happens when I assign[]
.TypeScript Version: 3.9.2, (also 3.8.3)
Search Terms:
I tried searching whether a similar issue has already raised with these keywords
is:issue never type parameter "extends never" conditional "<never>"
.Code
Expected behavior:
MyType0
becomestrue
as well asMyManual0
Actual behavior:
MyType0
becomesnever
Playground Link:
https://www.typescriptlang.org/play?#code/C4TwDgpgBAsiMEMB2BXBAbADFAvFJEAbhAE5QQAewESAJgM75GlQD8UwJK0AXFAGYZ6EANxQA9OI5dogXg3AsjsAoUJFjxkadAEZcUFEgDWSAPYB3JOSo0GTYmXaduUPoPTCxkgULlLl4aHAA4jSkAJYAxgA8ACoAfLrRltR0jAR2bNJOLt4iin6qcNH+2HhBISQRkWmksR5S1WSAfBuAKLv5ASBFkDqlIMEEFVH6RmZItRJSrsJQCm1qnRAATLpl-ZXIIGOeAEbGxugQyNPyQA
Related Issues:
The text was updated successfully, but these errors were encountered: