提交 61a2faf7 编写于 作者: J Johannes Rieken

debt - remove declaration for WinJS.Promise#any

上级 fb75f32b
......@@ -23,8 +23,6 @@ export class Promise<T = any> {
public static join<T1, T2>(promises: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
public static join<T>(promises: (T | PromiseLike<T>)[]): Promise<T[]>;
public static any<T>(promises: (T | PromiseLike<T>)[]): Promise<{ key: string; value: Promise<T>; }>;
public static wrap<T>(value: T | PromiseLike<T>): Promise<T>;
public static wrapError<T = never>(error: Error): Promise<T>;
......
......@@ -11,6 +11,10 @@ function isWinJSPromise(candidate: any): candidate is WinJSPromise {
return isThenable(candidate) && typeof (candidate as any).done === 'function';
}
declare class WinJSPromiseRemovals {
any<T=any>(promises: (T | PromiseLike<T>)[]): WinJSPromise<{ key: string; value: WinJSPromise<T>; }>;
}
/**
* A polyfill for the native promises. The implementation is based on
* WinJS promises but tries to gap differences between winjs promises
......@@ -33,7 +37,7 @@ export class PolyfillPromise<T = any> implements Promise<T> {
static race(thenables: Thenable<any>[]): PolyfillPromise {
// WinJSPromise returns `{ key: <index/key>, value: <promise> }`
// from the `any` call and Promise.race just wants the value
return new PolyfillPromise(WinJSPromise.any(thenables).then(entry => entry.value, err => err.value));
return new PolyfillPromise((WinJSPromise as any as WinJSPromiseRemovals).any(thenables).then(entry => entry.value, err => err.value));
}
static resolve(value): PolyfillPromise {
......
......@@ -55,8 +55,6 @@ declare namespace monaco {
public static join<T1, T2>(promises: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
public static join<T>(promises: (T | PromiseLike<T>)[]): Promise<T[]>;
public static any<T>(promises: (T | PromiseLike<T>)[]): Promise<{ key: string; value: Promise<T>; }>;
public static wrap<T>(value: T | PromiseLike<T>): Promise<T>;
public static wrapError<T = never>(error: Error): Promise<T>;
......
......@@ -234,7 +234,7 @@ export class LaunchService implements ILaunchService {
// is being used and only then resolve the startup promise which will kill this second instance.
// In addition, we poll for the wait marker file to be deleted to return.
if (args.wait && usedWindows.length === 1 && usedWindows[0]) {
return TPromise.any([
return Promise.race([
this.windowsMainService.waitForWindowCloseOrLoad(usedWindows[0].id),
whenDeleted(args.waitMarkerFilePath)
]).then(() => void 0, () => void 0);
......
......@@ -54,8 +54,8 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
canPickMany: options && options.canPickMany
}, token);
return TPromise.any(<TPromise<number | Item[]>[]>[quickPickWidget, itemsPromise]).then(values => {
if (values.key === '0') {
return Promise.race(<Thenable<false | Item[]>[]>[quickPickWidget.then(() => false), itemsPromise]).then(value => {
if (value === false) {
return undefined;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册