@@ -8,7 +8,72 @@ async function fAsyncExplicit(): Promise<[number, boolean]> {
88 // This is contextually typed as a tuple.
99 return [ 1 , true ] ;
1010}
11-
11+
12+ // https://github.com/Microsoft/TypeScript/issues/13128
13+ interface Obj {
14+ stringProp: string ;
15+ anyProp: any ;
16+ }
17+
18+ async function fIndexedTypeForStringProp ( obj : Obj ) : Promise < Obj [ "stringProp" ] > {
19+ return obj . stringProp ;
20+ }
21+
22+ async function fIndexedTypeForPromiseOfStringProp ( obj : Obj ) : Promise < Obj [ "stringProp" ] > {
23+ return Promise . resolve ( obj . stringProp ) ;
24+ }
25+
26+ async function fIndexedTypeForExplicitPromiseOfStringProp ( obj : Obj ) : Promise < Obj [ "stringProp" ] > {
27+ return Promise . resolve < Obj [ "stringProp" ] > ( obj . stringProp ) ;
28+ }
29+
30+ async function fIndexedTypeForAnyProp ( obj : Obj ) : Promise < Obj [ "anyProp" ] > {
31+ return obj . anyProp ;
32+ }
33+
34+ async function fIndexedTypeForPromiseOfAnyProp ( obj : Obj ) : Promise < Obj [ "anyProp" ] > {
35+ return Promise . resolve ( obj . anyProp ) ;
36+ }
37+
38+ async function fIndexedTypeForExplicitPromiseOfAnyProp ( obj : Obj ) : Promise < Obj [ "anyProp" ] > {
39+ return Promise . resolve < Obj [ "anyProp" ] > ( obj . anyProp ) ;
40+ }
41+
42+ async function fGenericIndexedTypeForStringProp < TObj extends Obj > ( obj : TObj ) : Promise < TObj [ "stringProp" ] > {
43+ return obj . stringProp ;
44+ }
45+
46+ async function fGenericIndexedTypeForPromiseOfStringProp < TObj extends Obj > ( obj : TObj ) : Promise < TObj [ "stringProp" ] > {
47+ return Promise . resolve ( obj . stringProp ) ;
48+ }
49+
50+ async function fGenericIndexedTypeForExplicitPromiseOfStringProp < TObj extends Obj > ( obj : TObj ) : Promise < TObj [ "stringProp" ] > {
51+ return Promise . resolve < TObj [ "stringProp" ] > ( obj . stringProp ) ;
52+ }
53+
54+ async function fGenericIndexedTypeForAnyProp < TObj extends Obj > ( obj : TObj ) : Promise < TObj [ "anyProp" ] > {
55+ return obj . anyProp ;
56+ }
57+
58+ async function fGenericIndexedTypeForPromiseOfAnyProp < TObj extends Obj > ( obj : TObj ) : Promise < TObj [ "anyProp" ] > {
59+ return Promise . resolve ( obj . anyProp ) ;
60+ }
61+
62+ async function fGenericIndexedTypeForExplicitPromiseOfAnyProp < TObj extends Obj > ( obj : TObj ) : Promise < TObj [ "anyProp" ] > {
63+ return Promise . resolve < TObj [ "anyProp" ] > ( obj . anyProp ) ;
64+ }
65+
66+ async function fGenericIndexedTypeForKProp < TObj extends Obj , K extends keyof TObj > ( obj : TObj , key : K ) : Promise < TObj [ K ] > {
67+ return obj [ key ] ;
68+ }
69+
70+ async function fGenericIndexedTypeForPromiseOfKProp < TObj extends Obj , K extends keyof TObj > ( obj : TObj , key : K ) : Promise < TObj [ K ] > {
71+ return Promise . resolve ( obj [ key ] ) ;
72+ }
73+
74+ async function fGenericIndexedTypeForExplicitPromiseOfKProp < TObj extends Obj , K extends keyof TObj > ( obj : TObj , key : K ) : Promise < TObj [ K ] > {
75+ return Promise . resolve < TObj [ K ] > ( obj [ key ] ) ;
76+ }
1277
1378//// [asyncFunctionReturnType.js]
1479var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
@@ -31,3 +96,78 @@ function fAsyncExplicit() {
3196 return [ 1 , true ] ;
3297 } ) ;
3398}
99+ function fIndexedTypeForStringProp ( obj ) {
100+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
101+ return obj . stringProp ;
102+ } ) ;
103+ }
104+ function fIndexedTypeForPromiseOfStringProp ( obj ) {
105+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
106+ return Promise . resolve ( obj . stringProp ) ;
107+ } ) ;
108+ }
109+ function fIndexedTypeForExplicitPromiseOfStringProp ( obj ) {
110+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
111+ return Promise . resolve ( obj . stringProp ) ;
112+ } ) ;
113+ }
114+ function fIndexedTypeForAnyProp ( obj ) {
115+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
116+ return obj . anyProp ;
117+ } ) ;
118+ }
119+ function fIndexedTypeForPromiseOfAnyProp ( obj ) {
120+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
121+ return Promise . resolve ( obj . anyProp ) ;
122+ } ) ;
123+ }
124+ function fIndexedTypeForExplicitPromiseOfAnyProp ( obj ) {
125+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
126+ return Promise . resolve ( obj . anyProp ) ;
127+ } ) ;
128+ }
129+ function fGenericIndexedTypeForStringProp ( obj ) {
130+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
131+ return obj . stringProp ;
132+ } ) ;
133+ }
134+ function fGenericIndexedTypeForPromiseOfStringProp ( obj ) {
135+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
136+ return Promise . resolve ( obj . stringProp ) ;
137+ } ) ;
138+ }
139+ function fGenericIndexedTypeForExplicitPromiseOfStringProp ( obj ) {
140+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
141+ return Promise . resolve ( obj . stringProp ) ;
142+ } ) ;
143+ }
144+ function fGenericIndexedTypeForAnyProp ( obj ) {
145+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
146+ return obj . anyProp ;
147+ } ) ;
148+ }
149+ function fGenericIndexedTypeForPromiseOfAnyProp ( obj ) {
150+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
151+ return Promise . resolve ( obj . anyProp ) ;
152+ } ) ;
153+ }
154+ function fGenericIndexedTypeForExplicitPromiseOfAnyProp ( obj ) {
155+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
156+ return Promise . resolve ( obj . anyProp ) ;
157+ } ) ;
158+ }
159+ function fGenericIndexedTypeForKProp ( obj , key ) {
160+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
161+ return obj [ key ] ;
162+ } ) ;
163+ }
164+ function fGenericIndexedTypeForPromiseOfKProp ( obj , key ) {
165+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
166+ return Promise . resolve ( obj [ key ] ) ;
167+ } ) ;
168+ }
169+ function fGenericIndexedTypeForExplicitPromiseOfKProp ( obj , key ) {
170+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
171+ return Promise . resolve ( obj [ key ] ) ;
172+ } ) ;
173+ }
0 commit comments