Open alamenai opened 1 month ago
Hi, @alamenai. Could you please try the latest GL JS v3.5.2?
Hi @stepankuzmin , Thank you. Yes, I'll try it this weekend and get back to you.
I am using "mapbox-gl": "^3.5.2",
and getting exactly the same results.
It appears to be related to
// ...
getDefaultPosition(): ControlPosition {
return "top-left"; // Return the default position as a ControlPosition value
}
// ...
}```
It seems it's related to the @types/mapbox__mapbox-gl-draw
community typings conflict with the first-class GL JS typings.
I have a PR in for this:
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/70144
I don't know how versioning works, but that MR got merged. You should at least be able to manually set the branch/commit in your package.json.
Apologies from my side. A new error has reared its head.
The update works great when using yarn link
, but fails when installing the module the traditional way. MapBox has compiled their code to use Map$1
as the name of the type: I assume due to a build step and a name collision with the global Map
type which they also use… The types I’ve created conflict with that Map
, causing build errors.
I’m not sure how to fix these. Plus it’s hard to test, as everything works great when woking locally.
Hi @brookjordan,
Thanks for taking a stab at this. I think you could use the mapboxgl.Map
type in DefinitelyTyped instead of Map
to avoid collisions.
Could you help me out with the syntax. The types don’t seem to latch on properly. Maybe the way MapBox has transpiled everything has meant that TypeScript no longer recognises the namespaces?
My attempt was changing from this:
declare module "mapbox-gl" {
interface Map {
on<T extends MapboxDraw.DrawEventType>(type: T, listener: (event: EventOf<T>) => void): this;
off<T extends MapboxDraw.DrawEventType>(type: T, listener: (event: EventOf<T>) => void): this;
}
}
to this:
declare module "mapbox-gl" {
namespace mapboxgl {
interface Map {
on<T extends MapboxDraw.DrawEventType>(type: T, listener: (event: EventOf<T>) => void): this;
off<T extends MapboxDraw.DrawEventType>(type: T, listener: (event: EventOf<T>) => void): this;
}
}
}
@mapbox/mapbox-gl-draw: ^1.4.3, @mapbox/mapbox-gl-draw-static-mode: ^1.0.1, mapbox-gl: ^3.2.0,
Steps to Trigger Behavior
Code
Expected Behavior
Types compatible
Actual Behavior