This post was most recently updated on July 27th, 2022.2 min read.
This one is something that I keep running into. Visual Studio just throws an error for a missing helper __spreadArray in a library that you didn’t even know you had installed, and you’re not sure if it should – or even can – be updated.
I guess Visual Studio just refuses to give me a break :) But like with so many different issues, there are multiple fixes available!
So when trying to build your solution or start debugging in Visual Studio, you run into an error somewhat like this:
TS2343 (TS) This syntax requires an imported helper named '__spreadArray' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
Okay, so check out the steps below!
Time needed: 1 minute.
Fixing “This syntax requires an imported helper named ‘__spreadArray’ which does not exist in ‘tslib’. Consider upgrading your version of ‘tslib’ in Visual Studio
- Ignore the error
Just ignoring the error might work. There’s a non-zero chance that the error won’t actually stop you from building and debugging.
If actually DOES fail your build, proceed.
- Clean your solution and rebuild
If cleaning and rebuilding your solution still doesn’t help, well, there are more steps below.
- Restart Visual Studio
This sounds stupid, but it might help – and even if it doesn’t, restarting Visual Studio is reasonably quick to do. Nowadays, anyway.
- Update your tslib
Updating your tslib version might be helpful if you’re using an older version than 1.10.0. You should probably be running something more recent than that, as it was published sometime in 2019 :)
- Just reinstall the package
Ok, so if everything else fails, this has worked for me every single time.
Just run the command below:
npm install [email protected] --save
Or if you actually know which version you want to use, run it like this:
npm install [email protected][your-preferred-version]latest --save
Et voilà !
Did it help or not?