File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -160,3 +160,32 @@ getJSON('story.json').then(function(story: Story) {
160
160
} ) . then ( function ( ) {
161
161
( < HTMLElement > document . querySelector ( '.spinner' ) ) . style . display = 'none' ;
162
162
} ) ;
163
+
164
+ interface T1 {
165
+ __t1 : string ;
166
+ }
167
+
168
+ interface T2 {
169
+ __t2 : string ;
170
+ }
171
+
172
+ interface T3 {
173
+ __t3 : string ;
174
+ }
175
+
176
+ function f1 ( ) : Promise < T1 > {
177
+ return Promise . resolve ( { __t1 : "foo_t1" } ) ;
178
+ }
179
+
180
+ function f2 ( x : T1 ) : T2 {
181
+ return { __t2 : x . __t1 + ":foo_21" } ;
182
+ }
183
+
184
+ var x3 = f1 ( )
185
+ . then ( f2 , ( e : Error ) => {
186
+ console . log ( "error 1" ) ;
187
+ throw e ;
188
+ } )
189
+ . then ( ( x : T2 ) => {
190
+ return { __t3 : x . __t2 + "bar" } ;
191
+ } ) ;
Original file line number Diff line number Diff line change 4
4
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
5
6
6
interface Thenable < R > {
7
- then < U > ( onFulfilled ?: ( value : R ) => U | Thenable < U > , onRejected ?: ( error : any ) => U | Thenable < U > ) : Thenable < U > ;
7
+ then < U > ( onFulfilled ?: ( value : R ) => U | Thenable < U > , onRejected ?: ( error : any ) => U | Thenable < U > ) : Thenable < U > ;
8
+ then < U > ( onFulfilled ?: ( value : R ) => U | Thenable < U > , onRejected ?: ( error : any ) => void ) : Thenable < U > ;
8
9
}
9
10
10
11
declare class Promise < R > implements Thenable < R > {
@@ -27,7 +28,8 @@ declare class Promise<R> implements Thenable<R> {
27
28
* @param onFulfilled called when/if "promise" resolves
28
29
* @param onRejected called when/if "promise" rejects
29
30
*/
30
- then < U > ( onFulfilled ?: ( value : R ) => U | Thenable < U > , onRejected ?: ( error : any ) => U | Thenable < U > ) : Promise < U > ;
31
+ then < U > ( onFulfilled ?: ( value : R ) => U | Thenable < U > , onRejected ?: ( error : any ) => U | Thenable < U > ) : Promise < U > ;
32
+ then < U > ( onFulfilled ?: ( value : R ) => U | Thenable < U > , onRejected ?: ( error : any ) => void ) : Promise < U > ;
31
33
32
34
/**
33
35
* Sugar for promise.then(undefined, onRejected)
You can’t perform that action at this time.
0 commit comments