When compiling a typescript file with tsc -p .
I'm getting the following error
error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
9 async function fetchImages(param1: string): Promise<string[]> {
Compiling with the lib option tsc --lib es5
doesn't solve it
Could could someone explain a bit more about the --lib option and how this would fix it as it didn't in my case.
node -v
v19.9.0
tsc -v
Version 5.1.0-dev.20230512
tsconfig:
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Language and Environment */
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
/* Modules */
"module": "es6", /* Specify what module code is generated. */
"rootDir": ".", /* Specify the root folder within your source files. */
"baseUrl": ".", /* Specify the base directory to resolve non-relative module names. */
/* Emit */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
"outDir": "dist", /* Specify an output folder for all emitted files. */
/* Interop Constraints */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
/* Completeness */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}