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 · 2 comments
Open

Difficulties with typescript #188

robinmolen opened this issue Jan 9, 2025 · 2 comments

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

robinmolen added a commit to maykinmedia/react-leaflet-draw that referenced this issue Jan 14, 2025
Import `EditOptions` directly from 'leaflet' results into a "Cannot use namespace EditOptions as a type" error.
@robinmolen
Copy link
Author

I've added a PR: #189. I would like to hear your thoughts

robinmolen added a commit to open-formulieren/formio-builder that referenced this issue Jan 14, 2025
The React-leaflet-draw package seems abandoned. As such, a fix for the typescript issue (alex3165/react-leaflet-draw#188) probably won't happen anytime soon

The .patch file, in `/patches`, contains the fix needed for the react-leaflet-draw index.d.ts file.

The problem with this solution, is that this only solves it for this project. If we introduce typescript to the SDK (or any other project using `react-leaflet-draw`), this problem will need to be solved again
robinmolen added a commit to open-formulieren/formio-builder that referenced this issue Jan 14, 2025
The React-leaflet-draw package seems abandoned. As such, a fix for the typescript issue (alex3165/react-leaflet-draw#188) probably won't happen anytime soon

The .patch file, in `/patches`, contains the fix needed for the react-leaflet-draw index.d.ts file.

The problem with this solution, is that this only solves it for this project. If we introduce typescript to the SDK (or any other project using `react-leaflet-draw`), this problem will need to be solved again
robinmolen added a commit to open-formulieren/formio-builder that referenced this issue Jan 14, 2025
The React-leaflet-draw package seems abandoned. As such, a fix for the typescript issue (alex3165/react-leaflet-draw#188) probably won't happen anytime soon

The .patch file, in `/patches`, contains the fix needed for the react-leaflet-draw index.d.ts file.

The problem with this solution, is that this only solves it for this project. If we introduce typescript to the SDK (or any other project using `react-leaflet-draw`), this problem will need to be solved again
robinmolen added a commit to open-formulieren/formio-builder that referenced this issue Jan 15, 2025
The React-leaflet-draw package seems abandoned. As such, a fix for the typescript issue (alex3165/react-leaflet-draw#188) probably won't happen anytime soon

The .patch file, in `/patches`, contains the fix needed for the react-leaflet-draw index.d.ts file.

The problem with this solution, is that this only solves it for this project. If we introduce typescript to the SDK (or any other project using `react-leaflet-draw`), this problem will need to be solved again
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