WebStorm IDEを使用してtypescript(ES6)でテストを書き込もうとしています。例えば:WebStorm IDEはasync() =>
WebStorm、ES5/ES3の非同期関数またはメソッドで 'Promise'コンストラクタが必要です
TS2705で次のエラーを示しているが
// Imports... describe('Message',() => { const server = express(); server.use(bodyParser.json()); const messageService = { findAll:() => ['test'] }; beforeAll(async() => { const module = await Test.createTestingModule({ modules: [MessageModule], })... }); // Tests... });
:ES5/ES3で非同期関数またはメソッドがプロミス コンストラクタを必要とします。 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"
]
}
私はts An async function or method in ES5/ES3 requires the 'Promise' constructorを読んで、それがどんな効果を持っていないしかし
"lib": [ "es2015" ]
を追加してみました。どのようなアイデアが間違っている?
が含まれています/除外が問題でした、ありがとうございました:) –