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

Difficulties with typescript #188

Open
robinmolen opened this issue Jan 9, 2025 · 1 comment
Open

Difficulties with typescript #188

robinmolen opened this issue Jan 9, 2025 · 1 comment

Comments

@robinmolen
Copy link

robinmolen commented Jan 9, 2025

Hai, im trying to use react-leaflet-draw version 0.20.4 with typescript, but im having some difficulty getting things to work. I'm wondering if you have any suggestions, and if these issues are known.

Dependencies

So im working with these packages:

"@types/leaflet": "^1.9.8",
"@types/leaflet-draw": "^1.0.11",
"leaflet": "^1.9.4",
"leaflet-draw": "^1.0.4",
"react-leaflet": "^4.2.1",
"react-leaflet-draw": "^0.20.4",

Errors

So im receiving typescript errors for node_modules/react-leaflet-draw/src/index.d.ts. Depending on which types dependencies i use, i get different errors:

When using the types for leaflet and leaflet-draw

"@types/leaflet": "^1.9.16",
"@types/leaflet-draw": "^1.0.11",

I get this error message node_modules/react-leaflet-draw/src/index.d.ts:25:9 - error TS2709: Cannot use namespace 'EditOptions' as a type.


With just the leaflet type

"@types/leaflet": "^1.9.16",

I get these error messages

node_modules/react-leaflet-draw/src/index.d.ts:3:2 - error TS2305: Module '"leaflet"' has no exported member 'DrawOptions'.
node_modules/react-leaflet-draw/src/index.d.ts:4:2 - error TS2724: '"leaflet"' has no exported member named 'EditOptions'. Did you mean 'setOptions'?
node_modules/react-leaflet-draw/src/index.d.ts:6:2 - error TS2305: Module '"leaflet"' has no exported member 'DrawEvents'.

Tried solutions

  1. So i've tried pinning @types/leaflet to the version you use 1.7.11, but this just results into the previous error messages + a couple extra..

  2. Setting "skipLibCheck": true in my tsconfig.json does solve it, but i really want to avoid doing this (as it feels a bit to aggressive)

@robinmolen
Copy link
Author

I think i found a solution for it. I'll try to make a PR later this week

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

No branches or pull requests

1 participant