![](/img/trans.png)
[英]WebStorm hints me the TS error (TS2705) when I use jest(ts-jest async/await test)
[英]TS2705 Error in Visual Studio: An async function or method in ES5/ES3 requires the 'Promise' constructor
我知道这个错误已经在几篇文章中讨论过,但是在遵循所有解决方案之后我无法避免这个错误。
我正在 VS 2017 中开发一个 React 应用程序。
以下代码导致我出现错误。 下面我还分享了 tsconfig 文件,其中包括"lib":["es2015"]
。 任何想法如何解决这个问题?
const fetchData = async () => {//Promise<void> =>
var dd = await axios.get('api/FeedbackComment/FetchFeedbackActivityByDate',
{
params: {
//activityDate: d3.timeParse("%Y-%m-%d")(d.dateCreated),
reviewRoundId: props.reviewRoundId,
submissionId: props.submissionId,
}
})
}
下面是我的 tsconfig.js
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": false,
"isolatedModules": true,
"removeComments": false,
"sourceMap": true,
"target": "es6",
"allowJs": true,
"checkJs": false,
"jsx": "preserve",
"lib": [
"es2015"
//"es6",
//"dom"
],
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"resolveJsonModule": true,
"noEmit": true
},
"exclude": [
"node_modules",
//"wwwroot"
],
"include": [
"src/**/*",
"**/*.spec.ts"
//"src",
//"./src/myIndex.d.ts"
]
}
我通过将 ECMAScript 版本更改为 6.0 来消除此错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.