@@ -296,6 +296,30 @@ class C1 {
296
296
}
297
297
}
298
298
299
+ type S2 = {
300
+ a : string ;
301
+ b : string ;
302
+ } ;
303
+
304
+ function f90< T extends S2 , K extends keyof S2 > (x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) {
305
+ x1 = x2 ;
306
+ x1 = x3 ;
307
+ x1 = x4 ;
308
+ x2 = x1 ;
309
+ x2 = x3 ;
310
+ x2 = x4 ;
311
+ x3 = x1 ;
312
+ x3 = x2 ;
313
+ x3 = x4 ;
314
+ x4 = x1 ;
315
+ x4 = x2 ;
316
+ x4 = x3 ;
317
+ x1 . length ;
318
+ x2 . length ;
319
+ x3 . length ;
320
+ x4 . length ;
321
+ }
322
+
299
323
// Repros from #12011
300
324
301
325
class Base {
@@ -429,7 +453,17 @@ type SomeMethodDescriptor = {
429
453
returnValue : string [ ] ;
430
454
}
431
455
432
- let result = dispatchMethod < SomeMethodDescriptor > ( "someMethod" , [ "hello" , 35 ] ) ;
456
+ let result = dispatchMethod < SomeMethodDescriptor > ( "someMethod" , [ "hello" , 35 ] ) ;
457
+
458
+ // Repro from #13073
459
+
460
+ type KeyTypes = "a" | "b"
461
+ let MyThingy : { [ key in KeyTypes ] : string [ ] } ;
462
+
463
+ function addToMyThingy < S extends KeyTypes > ( key : S ) {
464
+ MyThingy [ key ] . push ( "a" ) ;
465
+ }
466
+
433
467
434
468
//// [keyofAndIndexedAccess.js]
435
469
var __extends = ( this && this . __extends ) || function ( d , b ) {
@@ -644,6 +678,24 @@ var C1 = (function () {
644
678
} ;
645
679
return C1 ;
646
680
} ( ) ) ;
681
+ function f90 ( x1 , x2 , x3 , x4 ) {
682
+ x1 = x2 ;
683
+ x1 = x3 ;
684
+ x1 = x4 ;
685
+ x2 = x1 ;
686
+ x2 = x3 ;
687
+ x2 = x4 ;
688
+ x3 = x1 ;
689
+ x3 = x2 ;
690
+ x3 = x4 ;
691
+ x4 = x1 ;
692
+ x4 = x2 ;
693
+ x4 = x3 ;
694
+ x1 . length ;
695
+ x2 . length ;
696
+ x3 . length ;
697
+ x4 . length ;
698
+ }
647
699
// Repros from #12011
648
700
var Base = ( function ( ) {
649
701
function Base ( ) {
@@ -713,6 +765,10 @@ function f(p) {
713
765
a [ p ] . add ; // any
714
766
}
715
767
var result = dispatchMethod ( "someMethod" , [ "hello ", 35 ] ) ;
768
+ var MyThingy ;
769
+ function addToMyThingy ( key ) {
770
+ MyThingy [ key ] . push ( "a" ) ;
771
+ }
716
772
717
773
718
774
//// [keyofAndIndexedAccess.d.ts]
@@ -848,6 +904,11 @@ declare class C1 {
848
904
set < K extends keyof this > ( key : K , value : this [ K ] ) : void ;
849
905
foo ( ) : void ;
850
906
}
907
+ declare type S2 = {
908
+ a : string ;
909
+ b : string ;
910
+ } ;
911
+ declare function f90< T extends S2 , K extends keyof S2 > (x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]): void;
851
912
declare class Base {
852
913
get < K extends keyof this > ( prop : K ) : this [ K ] ;
853
914
set < K extends keyof this > ( prop : K , value : this [ K ] ) : void ;
@@ -920,3 +981,8 @@ declare type SomeMethodDescriptor = {
920
981
returnValue : string [ ] ;
921
982
} ;
922
983
declare let result: string[];
984
+ declare type KeyTypes = "a" | "b";
985
+ declare let MyThingy: {
986
+ [ key in KeyTypes ] : string [ ] ;
987
+ } ;
988
+ declare function addToMyThingy< S extends KeyTypes > (key: S): void;
0 commit comments