elfalem / Leaflet.curve

A Leaflet plugin for drawing Bézier curves and other complex shapes.
Other
218 stars 52 forks source link

Type declaration not published to NPM #40

Closed LanceEa closed 3 years ago

LanceEa commented 3 years ago

The type declaration file was added in #38. However, it looks like the declaration file is not being published to NPM so it doesn't show up in the node_modules/@elfalem/leaflet-curve.

Screen Shot 2021-07-12 at 10 30 45 AM

Based on the Typescript docs the two main ways are either via NPM with the library or through the @types organization on NPM. https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html

The previous PR included the types in the package.json and I also see someone already has submitted a version to the @types organization that separate from the ones included in this repository.

https://www.typescriptlang.org/dt/search?search=leaflet-curve

So, my guess is that it just got missed during the npm publish process?

elfalem commented 3 years ago

Thanks for reporting this. I have published a new package (v0.8.1) to fix this.

LanceEa commented 3 years ago

I have pulled in 0.8.2 and verified the typings are now published to NPM.

Thanks for getting this resolved so quickly!

One other thing that might be beneficial in the Readme is to point out for Typescript is they should do the following:

import { curve, Curve } from 'leaflet';
import '@elfalem/leaflet-curve';

Based on the typings the curve is imported from the leaflet module and not from the leaflet-curve module. At first I was trying to import from leaflet-curve and only saw the internal types. Which in hindsight makes since because it is a plugin extending leaflet object.

Screen Shot 2021-07-13 at 12 15 42 PM

By importing from leaflet the code is properly compiled (in my cause Angular) so that the curve function hangs off the window.L global object.

elfalem commented 3 years ago

I've updated the Readme. Thanks for pointing this out!