@@ -409,6 +409,70 @@ function conditionalRelations6<T>(x: T extends { self: T } ? { t: T } : never) {
409409 const make = < V > (v: V): T extends { self : T } ? { t : T , v : V } : never => null ! ;
410410 x = make ( 1 ) ;
411411}
412+
413+ function conditionalRelations7< T > (
414+ x: T extends object ? { inner : [ T ] extends [ string ] ? { t : T } : never } : never,
415+ y: [T] extends [string] ? { t : T } : never,
416+ ) {
417+ x . inner = y ;
418+ y = x . inner ;
419+ }
420+
421+ declare function pickT< V > (v: { t : V } ): V;
422+ function conditionalRelations8< T > (x: T extends object ? { t : T } : never, t: T) {
423+ let r = pickT ( x ) ;
424+ r = t ;
425+ }
426+
427+ interface Box< X > { value : X }
428+ function conditionalRelations9< T > (
429+ x: Box< T extends { value : infer U } ? { t : T , u : U } : never > ,
430+ y: Box< T extends { value : infer U } ? { t : T , u : U } : never > ,
431+ ) {
432+ x = y ;
433+ y = x ;
434+ }
435+
436+ type Cond< T > = T extends { value : infer U } ? { t : T , u : U } : never;
437+ type Rec< T > = T extends object ? { next : Rec < T > , t : T } : never;
438+ function conditionalRelations10< T > (x: Cond< T > , y: T extends { value : infer U } ? { t : T , u : U } : never) {
439+ x = y ;
440+ y = x ;
441+ const make = < V > (v: V): Cond< T > => null ! ;
442+ x = make ( 1 ) ;
443+ }
444+ function conditionalRelations11< T > (x: Rec< T > , y: T extends object ? { next : Rec < T > , t : T } : never) {
445+ x = y ;
446+ y = x ;
447+ }
448+
449+ function conditionalRelations12< T , U > (x: T extends string ? T : never, y: T, z: T extends string ? U : never) {
450+ x = y ; // Error
451+ x = z ; // Error
452+ z = x ; // Error
453+ }
454+
455+ type ElementType =
456+ | { type : "text" ; text : string }
457+ | { type : "image" ; src : string } ;
458+ interface Page {
459+ addElement < T extends ElementType [ "type" ] | ( string & { } ) > (
460+ attrs : { type : T } & ( T extends ElementType [ "type" ]
461+ ? Partial < Omit < Extract < ElementType , { type : T } > , "type" >>
462+ : Record < string , any > ) ,
463+ ) : void ;
464+ }
465+ declare const returned : {
466+ addElement < T extends ElementType [ "type" ] | ( string & { } ) > (
467+ attrs : { type : T } & ( T extends ElementType [ "type" ]
468+ ? Partial < Omit < Extract < ElementType , { type : T } > , "type" >>
469+ : Record < string , any > ) ,
470+ ) : void ;
471+ } ;
472+ const page : Page = returned ;
473+
474+ declare let f : < A > (m: A, r: (a: A extends string ? A : 0) => void ) => void ;
475+ let g : < A > ( m : A , r : ( a : A extends string ? A : 0 ) => void ) => void = f ;
412476
413477
414478//// [conditionalTypes1.js]
@@ -537,6 +601,35 @@ function conditionalRelations6(x) {
537601 const make = ( v ) => null ;
538602 x = make ( 1 ) ;
539603}
604+ function conditionalRelations7(x, y) {
605+ x . inner = y ;
606+ y = x . inner ;
607+ }
608+ function conditionalRelations8(x, t) {
609+ let r = pickT ( x ) ;
610+ r = t ;
611+ }
612+ function conditionalRelations9(x, y) {
613+ x = y ;
614+ y = x ;
615+ }
616+ function conditionalRelations10(x, y) {
617+ x = y ;
618+ y = x ;
619+ const make = ( v ) => null ;
620+ x = make ( 1 ) ;
621+ }
622+ function conditionalRelations11(x, y) {
623+ x = y ;
624+ y = x ;
625+ }
626+ function conditionalRelations12(x, y, z) {
627+ x = y ; // Error
628+ x = z ; // Error
629+ z = x ; // Error
630+ }
631+ const page = returned;
632+ let g = f;
540633
541634
542635//// [conditionalTypes1.d.ts]
@@ -851,3 +944,75 @@ declare function conditionalRelations6<T>(x: T extends {
851944} ? {
852945 t : T ;
853946} : never): void;
947+ declare function conditionalRelations7< T > (x: T extends object ? {
948+ inner : [ T ] extends [ string ] ? {
949+ t : T ;
950+ } : never ;
951+ } : never, y: [T] extends [string] ? {
952+ t : T ;
953+ } : never): void;
954+ declare function pickT< V > (v: {
955+ t : V ;
956+ } ): V;
957+ declare function conditionalRelations8< T > (x: T extends object ? {
958+ t : T ;
959+ } : never, t: T): void;
960+ interface Box< X > {
961+ value : X ;
962+ }
963+ declare function conditionalRelations9< T > (x: Box< T extends {
964+ value : infer U ;
965+ } ? {
966+ t : T ;
967+ u : U ;
968+ } : never > , y: Box< T extends {
969+ value : infer U ;
970+ } ? {
971+ t : T ;
972+ u : U ;
973+ } : never > ): void;
974+ type Cond< T > = T extends {
975+ value : infer U ;
976+ } ? {
977+ t : T ;
978+ u : U ;
979+ } : never;
980+ type Rec< T > = T extends object ? {
981+ next : Rec < T > ;
982+ t : T ;
983+ } : never;
984+ declare function conditionalRelations10< T > (x: Cond< T > , y: T extends {
985+ value : infer U ;
986+ } ? {
987+ t : T ;
988+ u : U ;
989+ } : never): void;
990+ declare function conditionalRelations11< T > (x: Rec< T > , y: T extends object ? {
991+ next : Rec < T > ;
992+ t : T ;
993+ } : never): void;
994+ declare function conditionalRelations12< T , U > (x: T extends string ? T : never, y: T, z: T extends string ? U : never): void;
995+ type ElementType = {
996+ type : "text" ;
997+ text : string ;
998+ } | {
999+ type : "image" ;
1000+ src : string ;
1001+ } ;
1002+ interface Page {
1003+ addElement < T extends ElementType [ "type" ] | ( string & { } ) > ( attrs : {
1004+ type : T ;
1005+ } & ( T extends ElementType [ "type" ] ? Partial < Omit < Extract < ElementType , {
1006+ type : T ;
1007+ } > , "type" >> : Record < string , any > ) ) : void ;
1008+ }
1009+ declare const returned: {
1010+ addElement < T extends ElementType [ "type" ] | ( string & { } ) > ( attrs : {
1011+ type : T ;
1012+ } & ( T extends ElementType [ "type" ] ? Partial < Omit < Extract < ElementType , {
1013+ type : T ;
1014+ } > , "type" >> : Record < string , any > ) ) : void ;
1015+ } ;
1016+ declare const page: Page;
1017+ declare let f: < A > (m: A, r: (a: A extends string ? A : 0) => void ) => void ;
1018+ declare let g : < A > (m: A, r: (a: A extends string ? A : 0) => void ) => void ;
0 commit comments