From 04fcd7b7d4b61c74b8974df551f74ae6614cb926 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Sat, 12 Oct 2019 14:30:00 +0200 Subject: [PATCH 1/6] =?UTF-8?q?feat(lib/es2020):=20Add=C2=A0`Promise.allSe?= =?UTF-8?q?ttled(=E2=80=A6)`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/es2020.d.ts | 1 + src/lib/es2020.promise.d.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/lib/es2020.promise.d.ts diff --git a/src/lib/es2020.d.ts b/src/lib/es2020.d.ts index fb55d987ebb5e..57a24ab62ed3f 100644 --- a/src/lib/es2020.d.ts +++ b/src/lib/es2020.d.ts @@ -1,3 +1,4 @@ /// +/// /// /// diff --git a/src/lib/es2020.promise.d.ts b/src/lib/es2020.promise.d.ts new file mode 100644 index 0000000000000..16125b99a1903 --- /dev/null +++ b/src/lib/es2020.promise.d.ts @@ -0,0 +1,30 @@ +interface PromiseResolution { + status: "fulfilled"; + value: T; +} + +interface PromiseRejection { + status: "rejected"; + reason: any; +} + +type PromiseResult = PromiseResolution | PromiseRejection; + +interface PromiseConstructor { + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike]): Promise<[PromiseResult, PromiseResult]>; + allSettled(values: readonly (T | PromiseLike)[]): Promise[]>; +} From ee3df7f693450996d95a9540c2f7982a02610f1b Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Sat, 12 Oct 2019 14:40:00 +0200 Subject: [PATCH 2/6] =?UTF-8?q?test(lib):=20Update=C2=A0tests=20to=C2=A0ac?= =?UTF-8?q?count=20for=C2=A0`es2020.promise`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/libs.json | 1 + src/testRunner/unittests/config/commandLineParsing.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/libs.json b/src/lib/libs.json index 089689befdda1..ef8dd6b5758b7 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -40,6 +40,7 @@ "es2019.object", "es2019.string", "es2019.symbol", + "es2020.promise", "es2020.string", "es2020.symbol.wellknown", "esnext.bigint", diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 5c4998a750a6c..5322793c45a24 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.promise', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, From 829f9733a58b4a30646653a6967a659cc50e385c Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Mon, 14 Oct 2019 21:40:00 +0200 Subject: [PATCH 3/6] =?UTF-8?q?fix(lib/es2020):=20`Promise.allSettled(?= =?UTF-8?q?=E2=80=A6)`=20takes=C2=A0`Iterable`=C2=A0argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compiler/commandLineParser.ts | 1 + src/lib/es2020.promise.d.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f7ac250984abf..862b707ad7811 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -49,6 +49,7 @@ namespace ts { ["es2019.object", "lib.es2019.object.d.ts"], ["es2019.string", "lib.es2019.string.d.ts"], ["es2019.symbol", "lib.es2019.symbol.d.ts"], + ["es2020.promise", "lib.es2020.promise.d.ts"], ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], diff --git a/src/lib/es2020.promise.d.ts b/src/lib/es2020.promise.d.ts index 16125b99a1903..7f02bd25e602a 100644 --- a/src/lib/es2020.promise.d.ts +++ b/src/lib/es2020.promise.d.ts @@ -26,5 +26,5 @@ interface PromiseConstructor { allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult]>; allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike]): Promise<[PromiseResult, PromiseResult]>; - allSettled(values: readonly (T | PromiseLike)[]): Promise[]>; + allSettled(values: Iterable>): Promise[]>; } From 1b6c7711fec59c88471ff950f05d31801742ac95 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Tue, 15 Oct 2019 23:45:00 +0200 Subject: [PATCH 4/6] =?UTF-8?q?refactor(lib/es2020):=20Rename=20`Promise.a?= =?UTF-8?q?llSettled(=E2=80=A6)`=20return=C2=A0type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/es2020.promise.d.ts | 89 +++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/src/lib/es2020.promise.d.ts b/src/lib/es2020.promise.d.ts index 7f02bd25e602a..6ddcb60080e2c 100644 --- a/src/lib/es2020.promise.d.ts +++ b/src/lib/es2020.promise.d.ts @@ -1,14 +1,14 @@ -interface PromiseResolution { +interface PromiseResolvedResult { status: "fulfilled"; value: T; } -interface PromiseRejection { +interface PromiseRejectedResult { status: "rejected"; reason: any; } -type PromiseResult = PromiseResolution | PromiseRejection; +type PromiseSettledResult = PromiseResolvedResult | PromiseRejectedResult; interface PromiseConstructor { /** @@ -17,14 +17,77 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[PromiseResult, PromiseResult, PromiseResult]>; - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike]): Promise<[PromiseResult, PromiseResult]>; - allSettled(values: Iterable>): Promise[]>; + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult]>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: Iterable>): Promise[]>; } From be97a6b7488f4b81809d15e5d20d8daccbc162b7 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Thu, 19 Dec 2019 02:15:00 +0100 Subject: [PATCH 5/6] =?UTF-8?q?feat(lib/es2020):=20Simplify=C2=A0`Promise.?= =?UTF-8?q?allSettled(=E2=80=A6)`=20type=C2=A0declaration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/es2020.promise.d.ts | 68 ++----------------------------------- 1 file changed, 2 insertions(+), 66 deletions(-) diff --git a/src/lib/es2020.promise.d.ts b/src/lib/es2020.promise.d.ts index 6ddcb60080e2c..c43f16341e73d 100644 --- a/src/lib/es2020.promise.d.ts +++ b/src/lib/es2020.promise.d.ts @@ -17,7 +17,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; + allSettled(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult ? U : T[P]> }>; /** * Creates a Promise that is resolved with an array of results when all @@ -25,69 +25,5 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: readonly [T1 | PromiseLike, T2 | PromiseLike]): Promise<[PromiseSettledResult, PromiseSettledResult]>; - - /** - * Creates a Promise that is resolved with an array of results when all - * of the provided Promises resolve or reject. - * @param values An array of Promises. - * @returns A new Promise. - */ - allSettled(values: Iterable>): Promise[]>; + allSettled(values: Iterable): Promise ? U : T>[]>; } From 2929aad81a7dca0efab60f6c967de89a618b9e7a Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Thu, 2 Jan 2020 18:00:00 +0100 Subject: [PATCH 6/6] =?UTF-8?q?refactor(lib/es2020):=20Improve=C2=A0naming?= =?UTF-8?q?=20of=C2=A0`Promise.allSettled(=E2=80=A6)`=C2=A0types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/es2020.promise.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/es2020.promise.d.ts b/src/lib/es2020.promise.d.ts index c43f16341e73d..a996a99603e5d 100644 --- a/src/lib/es2020.promise.d.ts +++ b/src/lib/es2020.promise.d.ts @@ -1,4 +1,4 @@ -interface PromiseResolvedResult { +interface PromiseFulfilledResult { status: "fulfilled"; value: T; } @@ -8,7 +8,7 @@ interface PromiseRejectedResult { reason: any; } -type PromiseSettledResult = PromiseResolvedResult | PromiseRejectedResult; +type PromiseSettledResult = PromiseFulfilledResult | PromiseRejectedResult; interface PromiseConstructor { /** @@ -17,7 +17,8 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - allSettled(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult ? U : T[P]> }>; + allSettled(values: T): + Promise<{ -readonly [P in keyof T]: PromiseSettledResult ? U : T[P]> }>; /** * Creates a Promise that is resolved with an array of results when all