PaulLeCam / react-leaflet

React components for Leaflet maps
https://react-leaflet.js.org
Other
5.11k stars 883 forks source link

Typescript declaration seems to be broken at least for the Circle #1077

Open dennisat opened 1 year ago

dennisat commented 1 year ago

Bug report in v4

Before opening an issue, make sure to read the contributing guide and understand this is a bug tracker, not a support platform.

Please make sure to check the following boxes before submitting an issue.\ Issues opened without using this template will be closed unless they have a good reason not to follow this template.

Expected behavior

It looks like the types are broken or incomplete.

This import { Circle } import from 'react-leaflet/Circle'has this errorTS2307: Cannot find module 'react-leaflet/Circle' or its corresponding type declarations.`.

But even if we import it as this import { Circle } from 'react-leaflet/lib/Circle', there is another TS error for the radius property: Property 'radius' does not exist on type 'IntrinsicAttributes & CircleProps & RefAttributes<Circle<any>>'.;

For the last one, digging into the types of the leaflet@1.9.3 file: node_modules/@types/leaflet/index.d.ts, there is no CircleOptions interface.

The CircleOptions is used from your code in node_modules/@react-leaflet/core/lib/circle.d.ts as this interface CircleProps extends CircleOptions, PathProps.

Actual behavior

Steps to reproduce

Is TSX file, import he Circle according to the official documentation: import { Circle } from 'react-leaflet/Circle' and compile.

dennisat commented 1 year ago

Hello, is anybody there?

CasualEngineerZombie commented 1 year ago

The correct way of importing the Circle is import { Circle } from "react-leaflet";

dennisat commented 1 year ago

I have attempted this import as well, @CodePhilanthropist, and it seems that this is indeed the correct way it should be. However, I am still encountering the same issue.

Could someone provide the package versions of the dependencies listed below?

Here are my versions:

About the react-leaflet-google-layer, there is a problem when bumping to v 2.2.0, there is a typescript error that the type property of ReactLeafletGoogleLayer is not defined. Super strange error, but let's say that this is out of the scope.

dennisat commented 11 months ago

Strange, doesn't any body use typescript???

hooch commented 10 months ago

Using typescript here and this works fine?

import { Circle } from 'react-leaflet'
..
return (
    <Circle center={[latitude, longitude]} radius={3} />
)
SamuelGalantei4sea commented 7 months ago

I am facing the same problem. To get around the situation, I added //@ts-ignore