Closed
Description
TypeScript Version: Nightly
Search Terms:
- Promises
- Error Messages
- Compiler
Code
// es2018 feature on Promise Type (correct error behavior)
new Promise(() => {}).finally();
// es2020 feature on PromiseConstructor Type (wrong error behavior)
Promise.allSettled([]);
// esnext feature on PromiseConstructor Type (wrong error behavior)
Promise.any([]);
Expected behavior:
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.
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.
Actual behavior:
Property 'allSettled' does not exist on type 'PromiseConstructor'
.Property 'any' does not exist on type 'PromiseConstructor'
.
Playground Link:
Related Issues:
How To Resolve
- Replace key at https://github.com/microsoft/TypeScript/blob/master/src/compiler/utilities.ts#L559 by PromiseConstructor
- Replace key at https://github.com/microsoft/TypeScript/blob/master/src/compiler/utilities.ts#L599 by PromiseConstructor
- Replace key at https://github.com/microsoft/TypeScript/blob/master/src/compiler/utilities.ts#L606 by PromiseConstructor
- Change test at
- Change test at
Activity
Fixes microsoft#40929
[-]Better PromiseConstructor error message for newer versions of ECMAScript[/-][+]PromiseConstructor error message is not using the correct format for newer versions of ECMAScript[/+]DanielRosenwasser commentedon Oct 5, 2020
Thanks for catching that 🙂
fix(40929) PromiseConstructor error message for newer versions of ECM…