Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
58
rated 0 times [  60] [ 2]  / answers: 1 / hits: 73091  / 5 Years ago, thu, october 10, 2019, 12:00:00

When I'm trying to use spreading in typescript like:



.reduce((unique, x) => {
unique.some(element => element.machineName === x.machineName) ? unique : [...unique, x];
}


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?



Note: Project gets compiled fine and works. But red underlying in VS Code in annoying.


More From » typescript

 Answers
21

For VS Code the notification is based on the tsLib exports.
Actually nothing bad happens without doing anything, it is just lack of typing.


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 is added in 1.10.0 tsLib version:
https://github.com/microsoft/tslib/blob/1.10.0/tslib.es6.js


Update: Since some time passed, it is better to update version to 2.2.0 (based on last comments) or the latest.


[#51584] Wednesday, October 2, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;