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
exporttypeTupleHasIndex<Arrextendsany[],Iextendsnumber>=({[KinkeyofArr]: '1'}&Array<'0'>)[I];// ^ #15768, TS2536 `X cannot be used to index Y` on genericexporttypeInc=[1,2,3,4,5,6,7,8,9,10];exporttypeTupleToUnion<Rextendsany[],Iextendsnumber=0,Acc=never>={1: TupleToUnion<R,Inc[I],Acc|R[I]>,0: Acc}[TupleHasIndex<R,I>];typeTupleToUnionTest1=TupleToUnion<['a','b']>;// "a" | "b"typeTupleToUnionTest2=TupleToUnion<string[]>;// neverdeclarefunctiontoUnion<Rextendsstring[]>(arr: R): TupleToUnion<R>;consttest1=toUnion(['a','b']);constarr: ['a','b']=['a','b'];consttest2=toUnion(arr);// ^ both: expecting 'a'|'b', got never
Expected behavior: 'a'|'b'
Actual behavior: never
I'd reported a similar failure at #12290 (comment), though the thread had already been closed. These are possibly related to #16018, of generic types similarly failing when wrapped, even without functions.
Activity
KiaraGrouwstra commentedon Aug 25, 2017
I retested this again on master now, where
test2does in fact work. Closing as no longer relevant until I can find a new repro for master.