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
typeAA<Textendsstring>=TtypeBB<Textendsnumber>=TtypeCC<Textendsboolean>=T// x// Type 'A' does not satisfy the constraint 'string'.(2344)// Type 'B' does not satisfy the constraint 'number'.(2344)// Type 'C' does not satisfy the constraint 'boolean'.(2344)typeTest<A,B,C>=[A,B,C]extends[string,number,boolean]
? AA<A>|BB<B>|CC<C>
: never// ??: type Result = string | number | booleantypeResult=Test<string,number,boolean>// otypeTest2<A,B,C>=[A]extends[string]
? [B]extends[number]
? [C]extends[boolean]
? AA<A>|BB<B>|CC<C>
: never
: never
: never// otypeTest3<A,B,C>=Aextendsstring
? Bextendsnumber
? Cextendsboolean
? AA<A>|BB<B>|CC<C>
: never
: never
: never
π Actual behavior
In Test1 A, B and C are incompatible with type constraints. As a comparison, Test2 is passed.
We still can get the Result type even the Test1 doesn't pass the validation by the type checker
π Expected behavior
Don't sure about Test1 or Test2 which is valid.
Don't sure should we get the expected Result type when the advanced type doesn't pass the checker.
The text was updated successfully, but these errors were encountered:
The error that we couldn't deduce that the type parameter met the constraint occurs and the type declaration is otherwise unaffected; you can see this in code like
typeFoo<Textends1>=T;// M = 2typeM=Foo<2>;
What "should" happen here is effectively undefined behavior since the program contains a contradiction and thus any result will be "wrong" by some definition.
I'm not sure what causes [A] extends [T] to cause a narrowing of A -> T but not in the 3-tuple case. Seems fixable in principle
Bug Report
π Search Terms
conditional type on tuple
π Version & Regression Information
v4.5.2
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Result
type even the Test1 doesn't pass the validation by the type checkerπ Expected behavior
The text was updated successfully, but these errors were encountered: