WebStorm Typescript Compile Error,TS2697:An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.

I have a project with the following directories.

-root/

   - lib

     - index.ts

     - a.ts

     -tsconfig.json

   -src

-tsconfig.json

 

And I have 2 tsconfig.json, one is under lib, one is under root folder, and I want to compile file under lib with lib/tsconfig.json.

And this is my tsconfig.json under lib

{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmitHelpers": true,
"strictNullChecks": false,
"baseUrl": ".",
"declaration": true,
"outDir": "../release",
"lib": [
"dom",
"es2016"
]
},
"exclude": [
"node_modules",
"dist"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
},
"files": [
"index.ts"
]
}

 

And this is my Typescript compiler settings.

I have tried ‘use tsconfig.json', the result is the same.

 

I got the following error.

 

 

Any help is appreciated, Thank you.

 

3 comments

Please try unchecking 'Use TypeScript service' - does the problem persist? The service uses the nearest tsconfig where the current file is included; if no tsconfig.json files that include your file are found, it uses 'default' tsconfig.json. Your tsconfig.json in lib/ folder only includes a single file - index.ts

"files": [
"index.ts"
]

so, other .ts files in this folder don't have any config files associated with them... So, default settings are used by compiler service

1

Thank you for your quick reply, it solves my problems. I love webstorm !

0

Please sign in to leave a comment.