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

tsc throws an error as it can't find @react-leaflet/core/lib/context when "module": "preserve" is set in tsconfig.json #1141

Open
7 tasks done
40thieves opened this issue Aug 27, 2024 · 0 comments

Comments

@40thieves
Copy link

Bug report in v4

I'm running tsc with the preserve value for the module setting in tsconfig.json on a project with React Leaflet.

  • All peer dependencies are installed: React, ReactDOM and Leaflet.
  • Using the latest version of React and ReactDOM v18.
  • Using the supported version of Leaflet (v1.8.0 minimum) and its corresponding CSS file is loaded.
  • Using the latest v4 version of React-Leaflet.
  • The issue has not already been reported.
  • Make sure you have followed the quick start guide for Leaflet.
  • Make sure you have fully read the documentation and that you understand the limitations.

Expected behavior

No tsc errors are found.

Actual behavior

tsc throws the following errors:

node_modules/react-leaflet/lib/LayersControl.d.ts:9:65 - error TS2307: Cannot find module '@react-leaflet/core/lib/context' or its corresponding type declarations.

9     layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
                                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/react-leaflet/lib/LayersControl.d.ts:18:69 - error TS2307: Cannot find module '@react-leaflet/core/lib/context' or its corresponding type declarations.

18         layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/react-leaflet/lib/LayersControl.d.ts:30:69 - error TS2307: Cannot find module '@react-leaflet/core/lib/context' or its corresponding type declarations.

30         layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/react-leaflet/lib/SVGOverlay.d.ts:11:65 - error TS2307: Cannot find module '@react-leaflet/core/lib/context' or its corresponding type declarations.

11     layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 4 errors in 2 files.

Errors  Files
     3  node_modules/react-leaflet/lib/LayersControl.d.ts:9
     1  node_modules/react-leaflet/lib/SVGOverlay.d.ts:11

Steps to reproduce

I've made a minimal repro: https://github.com/40thieves/ts-react-leaflet which installs the relevant dependencies and configures tsconfig.json with the module: preserve setting. To reproduce, you need to:

  1. Clone & npm install
  2. Run npm run check

(apologies, I'm not sure StackBlitz would work as it's related to running tsc)

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