问题描述
当我尝试在打字稿中使用传播时:
When I'm trying to use spreading in typescript like:
.reduce((unique, x) => {
unique.some(element => element.machineName === x.machineName) ? unique : [...unique, x];
}
我收到来自 Visual Studio Code
的红色标记警告:
I get warning with red marking from Visual Studio Code
:
the syntax requires an imported helper named __spreadArrays
typescript version: "2.3.4"
target: "es5"
我认为在以后的版本中这个问题得到了解决,但现在我无法迁移.我该如何解决?
I think in later versions this issue is fixed, but right now I can't migrate. How can I fix it?
注意: 项目可以正常编译并运行.但是VS Code
中的红色底层很烦人.
Note: Project gets compiled fine and works. But red underlying in VS Code
in annoying.
推荐答案
对于 VS Code
,通知基于 tsLib 导出.其实什么都不做也没什么不好的,就是没打字.
For VS Code
the notification is based on the tsLib exports.Actually nothing bad happens without doing anything, it is just lack of typing.
解决方案: 更新 tsLib 依赖项以消除突出显示.就我而言,它是版本 1.9.0
.更新到 1.10.0
解决了这个问题.
Solution: Update tsLib dependency to get rid of the highlighting. In my case it was version 1.9.0
. Update to 1.10.0
solved the issue.
__spreadArrays
添加在 1.10.0
tsLib
版本中:https://github.com/microsoft/tslib/blob/1.10.0/tslib.es6.js
__spreadArrays
is added in 1.10.0
tsLib
version:https://github.com/microsoft/tslib/blob/1.10.0/tslib.es6.js
更新:由于一段时间过去了,最好将版本更新到 2.2.0
(基于最后的评论)或 latest
.
Update: Since some time passed, it is better to update version to 2.2.0
(based on last comments) or the latest
.
这篇关于语法需要一个名为 __spreadArrays 的导入助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!