I tried to import functions in index.ts.
My codes
const functions = await import("./avs-directory/index").then(
(m) => {
return m;
}
);
I got errors like
tsc -p tsconfig.json
error TS2318: Cannot find global type 'Promise'.
index.ts:51:25 - error TS2711: A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option.
51 const functions = await import("./avs-directory/index").then(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors in the same file, starting at: index.ts:51
my tsconfig.json is
{
"extends": "assemblyscript/std/portable.json",
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
/* Language and Environment */
"target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2015", "ES2015.Promise"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
/* Modules */
"module": "es2022", /* Specify what module code is generated. */
/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"ts-node": {
"compilerOptions": {
"module": "ES2015"
}
},
"include": ["./**/*.ts", "index.ts", "runner.ts", "env.d.ts"],
"exclude": ["node_modules", "dist"]
}
what is the problem with my tsconfig.json? thanks
I tried to change the tsconfig.json based the error message but still got errors.
any idea why?
New contributor
Chengcheng Pei is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.