如何在WebStorm/IntelliJ中禁用TS80006异步函数转换警告?
在WebStorm中禁用TS80006警告("This may be converted to an async function")
需要禁用的警告代码为 TS80006,提示内容为:
This may be converted to an async function.
该警告表现为函数名被下划线标注,鼠标悬停时会弹出对应提示文本。
问题背景
原本预期在Settings / Editor / Inspections中找到该警告的开关,但搜索async function、quick fix、inspections等关键词均无结果(推测WebStorm与IntelliJ的设置逻辑一致)。
触发警告的代码示例:
const f = (): Promise<string[]> => { return util() .then( mapFunction1 ) .then( mapFunction2 ); };
WebStorm建议的修改方案(用户不偏好此写法,更倾向保留.then()链式调用):
const f = async (): Promise<string[]> => { const s = await util(); const s_1 = await mapFunction1( s ); return mapFunction2( s_1 ); };
已尝试但无效的操作
参考相关建议后,已在Settings / Editor / Intentions中禁用了Convert to async function选项,但警告仍未完全消失:快速修复菜单中的对应选项已移除,但代码中的下划线标注和悬停提示依旧存在。
内容的提问来源于stack exchange,提问作者kca
相关产品推荐
相关产品推荐

