【发布时间】:2020-07-31 22:05:37
【问题描述】:
我正在编写将在异步函数中评估的代码。此代码未包装在此文件中的函数中,因此所有“等待”都带有下划线作为检查错误。
有没有办法告诉 IDE 它是异步上下文并且所有“等待”都可以?
UPD 1:
代码评估:
const m = {};
const AF = Object.getPrototypeOf(async function(){}).constructor;
async function evl(n){
if(typeof m[n] === t.U) await (new AF('imp', 'exp', await get('http://localhost/mdl/' + n + '.js')))(imp, o=>{m[n]=o});
return m[n];
}
代码来源:
const message = await imp('message'); // await gives inspection error.
exp((name)=>console.log(message + ', ' + name + '!'));
【问题讨论】:
-
您可以suppress certain inspections 获取该文件,但我更想知道您的代码是什么样的以及您是如何评估它的?也许有一种方法可以在不违反规则的情况下编写您想要的内容?
-
@chazsolo 添加了一些代码。
标签: javascript asynchronous phpstorm webstorm jsdoc