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

Error when importing leaflet-geosearch using Vite/Typescript 5 #370

Closed
neilenns opened this issue Jul 10, 2023 · 3 comments · Fixed by #377
Closed

Error when importing leaflet-geosearch using Vite/Typescript 5 #370

neilenns opened this issue Jul 10, 2023 · 3 comments · Fixed by #377

Comments

@neilenns
Copy link

neilenns commented Jul 10, 2023

I'm attempting to use leaflet-geosearch in a React Typescript project created with Vite's react-ts template. I've done npm install leaflet-geosearch and imported it this way:

import "leaflet-geosearch/dist/geosearch.css";
import { GeoSearchControl, OpenStreetMapProvider } from "leaflet-geosearch";

Unfortunately typescript throws this error:

Could not find a declaration file for module 'leaflet-geosearch'. 'd:/git/test/test-app/node_modules/leaflet-geosearch/dist/geosearch.module.js' implicitly has an 'any' type.
  There are types at 'd:/git/test/test-app/node_modules/leaflet-geosearch/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'leaflet-geosearch' library may need to update its package.json or typings.

I've messed around with this for a while but can't get it to go away. I have no issues with the import or the types in a different React Typescript project that was created using create-react-app and Typescript version 4.

@GdevDdev
Copy link

GdevDdev commented Sep 5, 2023

I have exactly the same problem, I also hope to get a solution.

@ridhosatriawan
Copy link

same problem here 😢

achmadk added a commit to achmadk/leaflet-geosearch that referenced this issue Oct 4, 2023
…ipt 5

add `types` value into `exports`.[`.`] inside package.json file

fix smeijer#370
smeijer pushed a commit that referenced this issue Oct 4, 2023
fix #370

If it's not too much trouble, could you please add the
`hacktoberfest-accepted` tag to this PR?
@smeijer
Copy link
Owner

smeijer commented Oct 4, 2023

🎉 This issue has been resolved in version 3.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

4 participants