Skip to content
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

Typescript error Missing types for "js-cookie" after updating to latest version from 13.14.3 #892

Closed
JustFly1984 opened this issue Jan 13, 2020 · 18 comments · Fixed by #1859
Labels

Comments

@JustFly1984
Copy link

Missing types "@types/js-cookie": "^2.2.4"

After installing types, it errors out with incorrect import/export.

@JustFly1984
Copy link
Author

reverting back to 13.14.3 solves issue

@ayush987goyal
Copy link
Contributor

@streamich SI think this might be the issue with the useCookie hook. Should we move the @types/js-cookie from devDependencies to dependencies? Or should we re-export the single import of CookieAttributes from the package itself?

@ayush987goyal
Copy link
Contributor

@streamich Fixed with #894 and in v13.16.1. Can be closed.

@JustFly1984
Copy link
Author

Still having same issue with 13.16.1:
Screenshot 2020-01-15 04 42 30

@JustFly1984
Copy link
Author

please reopen

@ayush987goyal
Copy link
Contributor

Can you please set esModuleInterop flag to true in your tsconfig.json and try once?

@JustFly1984
Copy link
Author

setting up esModuleInterop itself to true is not enough, it also requires to set "allowSyntheticDefaultImports": true, to get rid of an error in react-use, but that causes a lot of other dependencies issues. I'm reverting it back.

@streamich streamich reopened this Jan 15, 2020
@ayush987goyal
Copy link
Contributor

Just tested v13.17.0 with scaffolding a new app with create-react-app TypeScript template and setting both esModuleInterop and allowSyntheticDefaultImports to false (it scaffolds with both set to true). It works without any issues. Maybe something else is not correct in your environment.

@ayush987goyal
Copy link
Contributor

@streamich We can make the js-cookie import to

import * as Cookies from 'js-cookie';

But I am not sure if we should do that

@streamich
Copy link
Owner

@ayush987goyal I don't think so, it should not matter how we internally import it, right?

@ayush987goyal
Copy link
Contributor

Yes that is correct. Therefore I gave it a try in a TS react project as mentioned above and it worked just fine.

@JustFly1984
Copy link
Author

I still have same issue with 13.18.0

Screenshot 2020-01-16 12 17 23

@JustFly1984
Copy link
Author

I guess issues could be with @types/js-cookies itself

@JustFly1984
Copy link
Author

Still having same issue in 13.20.0. Had cleaned ./cache, node_modules and yarn.lock file, still have same issue.

PS project is based on Gatsby.js. I'll try to make minimal reproduction on codesandbox.io

@makanti
Copy link

makanti commented Feb 1, 2021

@streamich Fixed with #894 and in v13.16.1. Can be closed.

Hello there, this issue has come back. It looks like the fix on #894 in v13.16.1 was reverted since then. It moved from Dependencies back to DevDependencies (Check here: v15.3.8...v17.0.2). I am trying to upgrade from v15.3.8 to v17.0.1 and this breaks the types. Any idea why has @types/js-cookie moved back to DevDependencies? Thanks! :)

image

@Paden
Copy link

Paden commented Feb 26, 2021

I am experiencing the same problem as @makanti. Any updates?

@streamich
Copy link
Owner

🎉 This issue has been resolved in version 17.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Hernanarica
Copy link

Hernanarica commented Sep 25, 2022

Pude encontrar la solucion para TypeScript, hay que instalar npm i js-cookie y npm i @types/js-cookie -D como devDependencie y tener ambos instalados

"dependencies": { "@heroicons/react": "^2.0.11", "@reduxjs/toolkit": "^1.8.5", "axios": "^0.27.2", "js-cookie": "^3.0.1", "moment": "^2.29.4", "react": "^18.0.0", "react-dom": "^18.0.0", "react-hook-form": "^7.36.0", "react-redux": "^8.0.2", "react-router-dom": "^6.4.1", "sweetalert2": "^11.4.33" }, "devDependencies": { "@types/js-cookie": "^3.0.2", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", "autoprefixer": "^10.4.12", "postcss": "^8.4.16", "tailwindcss": "^3.1.8", "typescript": "^4.6.3", "vite": "^2.9.15" } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants