Skip to main content
Correct product name spelling/capitalisation
Source Link
LazyOne
  • 166.8k
  • 49
  • 420
  • 422

Webstorm WebStorm, An async function or method in ES5/ES3 requires the 'Promise' constructor

I try to write tests in typescript (ES6) using WebstormWebStorm IDE. E.g.:

// Imports... describe('Message', () => { const server = express(); server.use(bodyParser.json()); const messageService = { findAll: () => ['test'] }; beforeAll(async () => { const module = await Test.createTestingModule({ modules: [MessageModule], })... }); // Tests... }); 

However WebstormWebStorm IDE shows following error at async () =>

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.

My tsconfig.json:

{ "compilerOptions": { "module": "commonjs", "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "sourceMap": true, "allowJs": true, "outDir": "./dist" }, "include": [ "src/**/*" ], "exclude": [ "node_modules", "**/*.spec.ts" ] } 

I read TypeScript compiler says “An async function or method in ES5/ES3 requires the 'Promise' constructor”; how do I solve this? and tried adding

"lib": [ "es2015" ] 

however it does not have any effect. Any ideas whatswhat's wrong?

Webstorm, An async function or method in ES5/ES3 requires the 'Promise' constructor

I try to write tests in typescript (ES6) using Webstorm IDE. E.g.:

// Imports... describe('Message', () => { const server = express(); server.use(bodyParser.json()); const messageService = { findAll: () => ['test'] }; beforeAll(async () => { const module = await Test.createTestingModule({ modules: [MessageModule], })... }); // Tests... }); 

However Webstorm IDE shows following error at async () =>

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.

My tsconfig.json:

{ "compilerOptions": { "module": "commonjs", "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "sourceMap": true, "allowJs": true, "outDir": "./dist" }, "include": [ "src/**/*" ], "exclude": [ "node_modules", "**/*.spec.ts" ] } 

I read TypeScript compiler says “An async function or method in ES5/ES3 requires the 'Promise' constructor”; how do I solve this? and tried adding

"lib": [ "es2015" ] 

however it does not have any effect. Any ideas whats wrong?

WebStorm, An async function or method in ES5/ES3 requires the 'Promise' constructor

I try to write tests in typescript (ES6) using WebStorm IDE. E.g.:

// Imports... describe('Message', () => { const server = express(); server.use(bodyParser.json()); const messageService = { findAll: () => ['test'] }; beforeAll(async () => { const module = await Test.createTestingModule({ modules: [MessageModule], })... }); // Tests... }); 

However WebStorm IDE shows following error at async () =>

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.

My tsconfig.json:

{ "compilerOptions": { "module": "commonjs", "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "sourceMap": true, "allowJs": true, "outDir": "./dist" }, "include": [ "src/**/*" ], "exclude": [ "node_modules", "**/*.spec.ts" ] } 

I read TypeScript compiler says “An async function or method in ES5/ES3 requires the 'Promise' constructor”; how do I solve this? and tried adding

"lib": [ "es2015" ] 

however it does not have any effect. Any ideas what's wrong?

Source Link
DarkLeafyGreen
  • 70.6k
  • 136
  • 394
  • 618

Webstorm, An async function or method in ES5/ES3 requires the 'Promise' constructor

I try to write tests in typescript (ES6) using Webstorm IDE. E.g.:

// Imports... describe('Message', () => { const server = express(); server.use(bodyParser.json()); const messageService = { findAll: () => ['test'] }; beforeAll(async () => { const module = await Test.createTestingModule({ modules: [MessageModule], })... }); // Tests... }); 

However Webstorm IDE shows following error at async () =>

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.

My tsconfig.json:

{ "compilerOptions": { "module": "commonjs", "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "sourceMap": true, "allowJs": true, "outDir": "./dist" }, "include": [ "src/**/*" ], "exclude": [ "node_modules", "**/*.spec.ts" ] } 

I read TypeScript compiler says “An async function or method in ES5/ES3 requires the 'Promise' constructor”; how do I solve this? and tried adding

"lib": [ "es2015" ] 

however it does not have any effect. Any ideas whats wrong?