@@ -7,6 +7,10 @@ class Shape {
77 visible : boolean ;
88}
99
10+ class TaggedShape extends Shape {
11+ tag : string ;
12+ }
13+
1014class Item {
1115 name : string ;
1216 price : number ;
@@ -149,6 +153,17 @@ function f32<K extends "width" | "height">(key: K) {
149153 return shape [ key ] ; // Shape[K]
150154}
151155
156+ function f33 < S extends Shape , K extends keyof S > ( shape : S , key : K ) {
157+ let name = getProperty ( shape , "name" ) ;
158+ let prop = getProperty ( shape , key ) ;
159+ return prop ;
160+ }
161+
162+ function f34 ( ts : TaggedShape ) {
163+ let tag1 = f33 ( ts , "tag" ) ;
164+ let tag2 = getProperty ( ts , "tag" ) ;
165+ }
166+
152167class C {
153168 public x : string ;
154169 protected y : string ;
@@ -164,4 +179,36 @@ function f40(c: C) {
164179 let x : X = c [ "x" ] ;
165180 let y : Y = c [ "y" ] ;
166181 let z : Z = c [ "z" ] ;
182+ }
183+
184+ // Repros from #12011
185+
186+ class Base {
187+ get < K extends keyof this> ( prop : K ) {
188+ return this [ prop ] ;
189+ }
190+ set < K extends keyof this> ( prop : K , value : this[ K ] ) {
191+ this [ prop ] = value ;
192+ }
193+ }
194+
195+ class Person extends Base {
196+ parts : number ;
197+ constructor ( parts : number ) {
198+ super ( ) ;
199+ this . set ( "parts" , parts ) ;
200+ }
201+ getParts ( ) {
202+ return this . get ( "parts" )
203+ }
204+ }
205+
206+ class OtherPerson {
207+ parts : number ;
208+ constructor ( parts : number ) {
209+ setProperty ( this , "parts" , parts ) ;
210+ }
211+ getParts ( ) {
212+ return getProperty ( this , "parts" )
213+ }
167214}
0 commit comments