Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 85cf3e3

Browse files
committed
Upgrade to typescript 2.5.2
Due to stricter generic type checks, signatures for ZoneAwarePromise need to be changed. See microsoft/TypeScript#16368 The signatures from lib.es5.d.ts were copied over for .then and .catch.
1 parent 326a07f commit 85cf3e3

File tree

4 files changed

+3227
-2860
lines changed

4 files changed

+3227
-2860
lines changed

lib/common/promise.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
207207
}
208208
}
209209

210-
function scheduleResolveOrReject<R, U>(
211-
promise: ZoneAwarePromise<any>, zone: AmbientZone, chainPromise: ZoneAwarePromise<any>,
212-
onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): void {
210+
function scheduleResolveOrReject<R, U1, U2>(
211+
promise: ZoneAwarePromise<any>, zone: AmbientZone,
212+
chainPromise: ZoneAwarePromise<any>, onFulfilled?: (value: R) => U1,
213+
onRejected?: (error: any) => U2): void {
213214
clearRejectedNoCatch(promise);
214215
const delegate = (promise as any)[symbolState] ?
215216
(typeof onFulfilled === FUNCTION) ? onFulfilled : forwardResolution :
@@ -265,7 +266,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
265266
static all<R>(values: any): Promise<R> {
266267
let resolve: (v: any) => void;
267268
let reject: (v: any) => void;
268-
let promise = new this((res, rej) => {
269+
let promise = new this<R>((res, rej) => {
269270
resolve = res;
270271
reject = rej;
271272
});
@@ -306,10 +307,13 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
306307
}
307308
}
308309

309-
then<R, U>(
310-
onFulfilled?: (value: R) => U | PromiseLike<U>,
311-
onRejected?: (error: any) => U | PromiseLike<U>): Promise<R> {
312-
const chainPromise: Promise<R> = new (this.constructor as typeof ZoneAwarePromise)(null);
310+
then<TResult1 = R, TResult2 = never>(
311+
onFulfilled?: ((value: R) => TResult1 | PromiseLike<TResult1>)|
312+
undefined|null,
313+
onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>)|
314+
undefined|null): Promise<TResult1|TResult2> {
315+
const chainPromise: Promise<TResult1|TResult2> =
316+
new (this.constructor as typeof ZoneAwarePromise)(null);
313317
const zone = Zone.current;
314318
if ((this as any)[symbolState] == UNRESOLVED) {
315319
(<any[]>(this as any)[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected);
@@ -319,7 +323,9 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
319323
return chainPromise;
320324
}
321325

322-
catch<U>(onRejected?: (error: any) => U | PromiseLike<U>): Promise<R> {
326+
catch<TResult = never>(
327+
onRejected?: ((reason: any) => TResult | PromiseLike<TResult>)|
328+
undefined|null): Promise<R|TResult> {
323329
return this.then(null, onRejected);
324330
}
325331
}

0 commit comments

Comments
 (0)