smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.02k stars 270 forks source link

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

Closed neilenns closed 9 months ago

neilenns commented 12 months ago

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 commented 10 months ago

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

ridhosatriawan commented 9 months ago

same problem here 😢

smeijer commented 9 months ago

:tada: This issue has been resolved in version 3.10.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: