-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TypeScript error “TS2354: This syntax requires an imported helper but module 'tslib' cannot be found” #37991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was having this exact same issue and I figured it out! Add to paths in tsconfig.json. And in your case, you will need to add "baseUrl" too.
|
thanks gus!!! |
Seeing this error when opening Yarn PnP project in VIM. |
Facing similar issue while migrating from Yarn 1.x to Yarn 2.x (which uses Edit: This might help someone who wants to dig in more: #28289 |
Has anyone found a solution for this issue (with Yarn v2)? |
Seems like our checker is incorrectly checking for lib helpers in cases where they're not needed. We shouldn't need to check for them when using |
I'm also seeing this error in JavaScript files when running with |
Ditto on object destructuring triggering the error. I can't use the
(nb installing EDIT: further information. I can now make the error go away by either disabling incremental compilation, or deleting the |
just came accross this. can anyone provide cleaner solution, than adding ts-with npm? much appriciated. |
Using yarn pnp this can be overcome by executing tsc with yarn pnpify.
|
I have a fix up for the commonjs The reason for the issue in the OP is twofold. First, we were detecting the file is a module due to the |
No matter what I do in the internet I still get the error.
This syntax requires an imported helper named '__spreadArray' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.ts(2343) |
I got the same __spreadArray error in my project. I npm i tslib to ^2.2.0 and the error is gone. |
Thank you. |
For those using pnp, you need to resolve the pnp path within tsconfig in your "compilerOptions":
|
This error might happen if you have in your tsconfig.json file :
If for any reason you can't upgrade to es6, setting importHelpers to false will make the error go away ... |
TypeScript Version: 3.8.3
Search Terms: TS2354
Code
package.json
tsconfig.json
index.js
Expected behavior:
Actual behavior:
I have reduced a problem with TypeScript to a simple example. When trying to run tsc, I get the following error message but tslib should be available.
Playground Link: https://codesandbox.io/s/quizzical-mclean-n9vvi?fontsize=14&hidenavigation=1&theme=dark
Related Issues:
The text was updated successfully, but these errors were encountered: