fix(40929) PromiseConstructor error message for newer versions of ECMAScript (#40931)

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Fixes #40929

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
This commit is contained in:
Vincent Boivin 2020-10-05 19:38:12 -04:00 committed by GitHub
parent 1191e2e731
commit 57661607e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 29 deletions

View file

@ -556,7 +556,8 @@ namespace ts {
Math: ["clz32", "imul", "sign", "log10", "log2", "log1p", "expm1", "cosh", "sinh", "tanh", "acosh", "asinh", "atanh", "hypot", "trunc", "fround", "cbrt"],
Map: ["entries", "keys", "values"],
Set: ["entries", "keys", "values"],
Promise: ["all", "race", "reject", "resolve"],
Promise: emptyArray,
PromiseConstructor: ["all", "race", "reject", "resolve"],
Symbol: ["for", "keyFor"],
WeakMap: ["entries", "keys", "values"],
WeakSet: ["entries", "keys", "values"],
@ -596,14 +597,14 @@ namespace ts {
BigInt: emptyArray,
BigInt64Array: emptyArray,
BigUint64Array: emptyArray,
Promise: ["allSettled"],
PromiseConstructor: ["allSettled"],
SymbolConstructor: ["matchAll"],
String: ["matchAll"],
DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"],
RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"]
},
esnext: {
Promise: ["any"],
PromiseConstructor: ["any"],
String: ["replaceAll"],
NumberFormat: ["formatToParts"]
}

View file

@ -24,11 +24,11 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(30,30): err
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(31,31): error TS2550: Property 'trimLeft' does not exist on type '""'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2019' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(32,32): error TS2550: Property 'trimRight' does not exist on type '""'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2019' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(33,45): error TS2550: Property 'description' does not exist on type 'symbol'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2019' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(36,53): error TS2550: Property 'allSettled' does not exist on type 'Promise<unknown>'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(36,39): error TS2550: Property 'allSettled' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(37,31): error TS2550: Property 'matchAll' does not exist on type '""'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(38,47): error TS2550: Property 'matchAll' does not exist on type 'SymbolConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(39,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(42,46): error TS2550: Property 'any' does not exist on type 'Promise<unknown>'. Do you need to change your target library? Try changing the `lib` compiler option to 'esnext' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(42,32): error TS2550: Property 'any' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'esnext' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(43,33): error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the `lib` compiler option to 'esnext' or later.
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,70): error TS2550: Property 'formatToParts' does not exist on type 'NumberFormat'. Do you need to change your target library? Try changing the `lib` compiler option to 'esnext' or later.
@ -122,9 +122,9 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,70): err
!!! error TS2550: Property 'description' does not exist on type 'symbol'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2019' or later.
// es2020
const testPromiseAllSettled = new Promise(() => {}).allSettled();
~~~~~~~~~~
!!! error TS2550: Property 'allSettled' does not exist on type 'Promise<unknown>'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
const testPromiseAllSettled = Promise.allSettled([]);
~~~~~~~~~~
!!! error TS2550: Property 'allSettled' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
const testStringMatchAll = "".matchAll();
~~~~~~~~
!!! error TS2550: Property 'matchAll' does not exist on type '""'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
@ -136,9 +136,9 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,70): err
!!! error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2020' or later.
// esnext
const testPromiseAny = new Promise(() => {}).any();
~~~
!!! error TS2550: Property 'any' does not exist on type 'Promise<unknown>'. Do you need to change your target library? Try changing the `lib` compiler option to 'esnext' or later.
const testPromiseAny = Promise.any([]);
~~~
!!! error TS2550: Property 'any' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'esnext' or later.
const testStringReplaceAll = "".replaceAll();
~~~~~~~~~~
!!! error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the `lib` compiler option to 'esnext' or later.

View file

@ -34,13 +34,13 @@ const testStringTrimRight = "".trimRight();
const testSymbolDescription = Symbol("foo").description;
// es2020
const testPromiseAllSettled = new Promise(() => {}).allSettled();
const testPromiseAllSettled = Promise.allSettled([]);
const testStringMatchAll = "".matchAll();
const testRegExpMatchAll = /matchAll/g[Symbol.matchAll]("matchAll");
const testBigInt = BigInt(123);
// esnext
const testPromiseAny = new Promise(() => {}).any();
const testPromiseAny = Promise.any([]);
const testStringReplaceAll = "".replaceAll();
const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts();
@ -76,11 +76,11 @@ var testStringTrimLeft = "".trimLeft();
var testStringTrimRight = "".trimRight();
var testSymbolDescription = Symbol("foo").description;
// es2020
var testPromiseAllSettled = new Promise(function () { }).allSettled();
var testPromiseAllSettled = Promise.allSettled([]);
var testStringMatchAll = "".matchAll();
var testRegExpMatchAll = /matchAll/g[Symbol.matchAll]("matchAll");
var testBigInt = BigInt(123);
// esnext
var testPromiseAny = new Promise(function () { }).any();
var testPromiseAny = Promise.any([]);
var testStringReplaceAll = "".replaceAll();
var testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts();

View file

@ -97,7 +97,7 @@ const testSymbolDescription = Symbol("foo").description;
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
// es2020
const testPromiseAllSettled = new Promise(() => {}).allSettled();
const testPromiseAllSettled = Promise.allSettled([]);
>testPromiseAllSettled : Symbol(testPromiseAllSettled, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 35, 5))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
@ -112,7 +112,7 @@ const testBigInt = BigInt(123);
>testBigInt : Symbol(testBigInt, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 38, 5))
// esnext
const testPromiseAny = new Promise(() => {}).any();
const testPromiseAny = Promise.any([]);
>testPromiseAny : Symbol(testPromiseAny, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 41, 5))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))

View file

@ -207,14 +207,13 @@ const testSymbolDescription = Symbol("foo").description;
>description : any
// es2020
const testPromiseAllSettled = new Promise(() => {}).allSettled();
const testPromiseAllSettled = Promise.allSettled([]);
>testPromiseAllSettled : any
>new Promise(() => {}).allSettled() : any
>new Promise(() => {}).allSettled : any
>new Promise(() => {}) : Promise<unknown>
>Promise.allSettled([]) : any
>Promise.allSettled : any
>Promise : PromiseConstructor
>() => {} : () => void
>allSettled : any
>[] : undefined[]
const testStringMatchAll = "".matchAll();
>testStringMatchAll : any
@ -240,14 +239,13 @@ const testBigInt = BigInt(123);
>123 : 123
// esnext
const testPromiseAny = new Promise(() => {}).any();
const testPromiseAny = Promise.any([]);
>testPromiseAny : any
>new Promise(() => {}).any() : any
>new Promise(() => {}).any : any
>new Promise(() => {}) : Promise<unknown>
>Promise.any([]) : any
>Promise.any : any
>Promise : PromiseConstructor
>() => {} : () => void
>any : any
>[] : undefined[]
const testStringReplaceAll = "".replaceAll();
>testStringReplaceAll : any

View file

@ -35,12 +35,12 @@ const testStringTrimRight = "".trimRight();
const testSymbolDescription = Symbol("foo").description;
// es2020
const testPromiseAllSettled = new Promise(() => {}).allSettled();
const testPromiseAllSettled = Promise.allSettled([]);
const testStringMatchAll = "".matchAll();
const testRegExpMatchAll = /matchAll/g[Symbol.matchAll]("matchAll");
const testBigInt = BigInt(123);
// esnext
const testPromiseAny = new Promise(() => {}).any();
const testPromiseAny = Promise.any([]);
const testStringReplaceAll = "".replaceAll();
const testNumberFormatFormatToParts = new Intl.NumberFormat("en-US").formatToParts();