I\'m using the mapbox-gl library with TypeScript, and I\'ve installed its community sourced type definitions with @types/mapbox-gl
. When I try to import and set an
Here's a temporary workaround I've been using:
Object.getOwnPropertyDescriptor(mapboxgl, "accessToken").set('YOUR_TOKEN');
Since the object was redefined to use a custom setter which places the token inside an internal closure - we can call the setter function directly as shown in the example.
Diving a little deeper, we can see that es6 modules are constants by definition: https://github.com/Microsoft/TypeScript/issues/6751#issuecomment-177114001
we can then do something like: (mapboxgl as any).accessToken = ..
. which will work.