@@ -7,6 +7,10 @@ class Shape {
7
7
visible : boolean ;
8
8
}
9
9
10
+ class TaggedShape extends Shape {
11
+ tag : string ;
12
+ }
13
+
10
14
class Item {
11
15
name : string ;
12
16
price : number ;
@@ -149,6 +153,17 @@ function f32<K extends "width" | "height">(key: K) {
149
153
return shape [ key ] ; // Shape[K]
150
154
}
151
155
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
+
152
167
class C {
153
168
public x : string ;
154
169
protected y : string ;
@@ -164,4 +179,36 @@ function f40(c: C) {
164
179
let x : X = c [ "x" ] ;
165
180
let y : Y = c [ "y" ] ;
166
181
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
+ }
167
214
}
0 commit comments