WebStorm,ES5 / ES3中的异步函数或方法需要'Promise'构造函数(WebStorm, An async function or method in ES5/ES3 requires the 'Promise' constructor)
我尝试使用WebStorm IDE在typescript(ES6)中编写测试。 例如:
// Imports...
describe('Message', () => {
const server = express();
server.use(bodyParser.json());
const messageService = { findAll: () => ['test'] };
beforeAll(async () => {
const module = await Test.createTestingModule({
modules: [MessageModule],
})...
});
// Tests...
});
但是,WebStorm IDE在async () =>显示以下错误
TS2705:ES5 / ES3中的异步函数或方法需要Promise构造函数。 确保您有Promise构造函数的声明或在--lib选项中包含ES2015。
我的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"
]