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

Commit 1acab39

Browse files
rkirovmhevery
authored andcommitted
build: Upgrade to typescript 2.5.2 (#924)
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 27499d4 commit 1acab39

File tree

4 files changed

+3223
-2859
lines changed

4 files changed

+3223
-2859
lines changed

lib/common/promise.ts

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

210-
function scheduleResolveOrReject<R, U>(
210+
function scheduleResolveOrReject<R, U1, U2>(
211211
promise: ZoneAwarePromise<any>, zone: AmbientZone, chainPromise: ZoneAwarePromise<any>,
212-
onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): void {
212+
onFulfilled?: (value: R) => U1, onRejected?: (error: any) => U2): void {
213213
clearRejectedNoCatch(promise);
214214
const delegate = (promise as any)[symbolState] ?
215215
(typeof onFulfilled === FUNCTION) ? onFulfilled : forwardResolution :
@@ -265,7 +265,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
265265
static all<R>(values: any): Promise<R> {
266266
let resolve: (v: any) => void;
267267
let reject: (v: any) => void;
268-
let promise = new this((res, rej) => {
268+
let promise = new this<R>((res, rej) => {
269269
resolve = res;
270270
reject = rej;
271271
});
@@ -306,10 +306,12 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
306306
}
307307
}
308308

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);
309+
then<TResult1 = R, TResult2 = never>(
310+
onFulfilled?: ((value: R) => TResult1 | PromiseLike<TResult1>)|undefined|null,
311+
onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>)|undefined|
312+
null): Promise<TResult1|TResult2> {
313+
const chainPromise: Promise<TResult1|TResult2> =
314+
new (this.constructor as typeof ZoneAwarePromise)(null);
313315
const zone = Zone.current;
314316
if ((this as any)[symbolState] == UNRESOLVED) {
315317
(<any[]>(this as any)[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected);
@@ -319,7 +321,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
319321
return chainPromise;
320322
}
321323

322-
catch<U>(onRejected?: (error: any) => U | PromiseLike<U>): Promise<R> {
324+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>)|undefined|
325+
null): Promise<R|TResult> {
323326
return this.then(null, onRejected);
324327
}
325328
}

0 commit comments

Comments
 (0)