-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Description
🔎 Search Terms
never, conditional, parameter, argument
🕗 Version & Regression Information
I did not exhaustively check older versions of TS yet. This issue feels like bug to me, but I don't know how to search for it as its a specific circumstance that has no particular label that I know of.
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
💻 Code
namespace check_is_never_extends_parameter {
type $<p> = never extends p ? true : false
type is_never_extends = $<1> // never extends 1 ? true : false
// true
type is_never_extends_never = $<never> // never extends never ? true : false
// true
}
namespace check_is_parameter_extends_never {
type $<p> = p extends never ? true : false
type is_never_extends_never = $<never> // never extends never ? true : false
// never <------------------------------------------------------------------ ???
type is_1_extends_never = $<1> // 1 extends never ? true : false
// false
}
namespace check_is_1_extends_parameter {
type $<p> = 1 extends p ? true : false
type is_1_extends_never = $<never> // 1 extends never ? true : false
// false
type is_1_extends_1 = $<1> // 1 extends 1 ? true : false
// true
}
namespace check_is_parameter_extends_1 {
type $<p> = p extends 1 ? true : false
type is_1_extends_never = $<never> // 1 extends never ? true : false
// never <---------------------------------------------------------- ???
type is_1_extends_1 = $<1> // 1 extends 1 ? true : false
// true
}
🙁 Actual behavior
Best way I can describe this so far:
never
given as a type argument- ... to a conditional type
- ... where the respective parameter is referenced in the sub-type-position of the conditional (
x (<-- sub-type position) extends y (<-- super-type position)
) - ... evaluates to
never
- ... instead of the conditional being evaluated (in this case,
true
/false
).
🙂 Expected behavior
I expect a types to be evaluated consistently when never is given as an argument.
Additional information about the issue
I hit this issue while working on my library https://graffle.js.org.
Metadata
Metadata
Assignees
Labels
No labels