WebStorm IDE를 사용하여 typescript (ES6)로 테스트를 작성하려고합니다. 예컨대 :WebStorm, ES5/ES3의 비동기 함수 또는 메소드에 'Promise'생성자가 필요합니다.
// 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 생성자에 대한 선언이 있는지 확인하거나 --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" ]
를 추가했습니다. 어떤 아이디어가 잘못된거야? 문제를 해결해야
"lib": [ "es2015" ]
tsconfig.json에 추가
포함/제외가 문제였습니다. 감사합니다. lena :) –