CliffCloud / Leaflet.EasyButton

leaflet control buttons with icons and callbacks
http://cliffcloud.github.io/Leaflet.EasyButton/v1/
MIT License
524 stars 123 forks source link

typescript build fails on 2.2.2 with leaflet 1.2.0 #71

Closed mgoldsborough closed 7 years ago

mgoldsborough commented 7 years ago

Hello,

I recently cleaned out my node_modules folder and reinstalled them via npm install. Prior to the update I had v2.2.0. After the update I was provided v2.2.2.

I'm now unable to build my project which utilizes leaflet v1.0.3.

Here's my dependency block:

"dependencies": {
    "leaflet": "=1.0.3",
    "leaflet-easybutton": "^2.2.0"
}

And the output of npm ls -depth 0 leaflet leaflet-easybutton:

myapp@0.0.0 /Users/me/Code/myapp
├── leaflet@1.0.3 
└── leaflet-easybutton@2.2.2 

And here are the build errors:

ERROR in [at-loader] ./node_modules/leaflet-easybutton/src/easy-button.d.ts:24:51 
    TS2694: Namespace '"/Users/username/Code/fo/fo-web-angular/node_modules/@types/leaflet/index".L' has no exported member 'Map'.
ERROR in [at-loader] ./node_modules/leaflet-easybutton/src/easy-button.d.ts:29:20 
    TS2304: Cannot find name 'ControlPosition'.
ERROR in [at-loader] ./node_modules/leaflet-easybutton/src/easy-button.d.ts:35:20 
    TS2304: Cannot find name 'ControlPosition'.
ERROR in [at-loader] ./node_modules/leaflet-easybutton/src/easy-button.d.ts:45:53 
    TS2694: Namespace '"/Users/username/Code/fo/fo-web-angular/node_modules/@types/leaflet/index".L' has no exported member 'Map'.
ERROR in [at-loader] ./node_modules/leaflet-easybutton/src/easy-button.d.ts:51:34 
    TS2507: Type 'typeof Control' is not a constructor function type.
ERROR in [at-loader] ./node_modules/leaflet-easybutton/src/easy-button.d.ts:55:31 
    TS2507: Type 'typeof Control' is not a constructor function type.

If I lock leaflet-easybutton to v2.2.0, everything works fine.

Any thoughts on what would be the issue?

atstp commented 7 years ago

The only change introduced in 2.2.2 is the addition of typescript bindings (the .d.ts file that is mentioned in your errors).

Are you using typescript?

mgoldsborough commented 7 years ago

@atstp yep, we are using typescript v2.3.4

sgentile commented 7 years ago

Have you tried using leaflet 1.2.0 ?

sgentile commented 7 years ago

let me take that back - your type definition file doesn't working with latest leaflet 1.2.0 - works with 1.0.66

atstp commented 7 years ago

@sgentile, are you referring to the EasyButton type definitions?

EasyButton's .d.ts file was contributed by the community (pinging @teyc); I'm not a typescript user myself. Regardless, I'd like to make sure that it all works smoothly and it seems like the workaround right now to pin at 2.2.0, just before the typescript definitions were added — not ideal.

As typescript users, do you guys have any hints as to why these errors are showing up or how to fix them? are you using any other leaflet plugins with typescript definitions that we could reference?

teyc commented 7 years ago

@atstp These errors are showing up because Typescript is a strongly typed language, and if it spots incompatible function definitions etc, it will complain ahead of time. Sounds like leaflet typings 1.2.0 has made significant changes to the API. https://github.com/DefinitelyTyped/DefinitelyTyped/commit/b5eaa88e9effe4eebf076951217bdaf3be861721#diff-e215c0498649a65783e8d1347a88e640L1308

This is going to be somewhat painful to resolve. Any suggestions what to do with such big changes?

atstp commented 7 years ago

Thanks teyc.

For now, I'll add a note to the readme. From what you guys have seen, is it correct to say that:

EasyButon's type definitons work with leaflet@1.0.66 and below; for compatibility with the latest leaflet pin leaflet-easybutton to 2.2.0 (for which aren't type definitions)

after that, we can address updating EasyButton's bindings at whatever speed works well for us. All of my typed js work right now is through bucklescript, but if i get the chance to do some typescript work i'll take the opportunity and update EasyButton.

In the meantime, if anyone from the community can updated the type definitions, I, along with the ret of the community, would appreciate it!

atstp commented 7 years ago

should be fixed with release v2.2.3