maptiler / maptiler-sdk-js

Maps SDK tailored for MapTiler Cloud powered by MapLibre GL JS
https://docs.maptiler.com/sdk-js/
BSD 3-Clause "New" or "Revised" License
79 stars 14 forks source link

LngLat is not available as a type/Class to import from @maptiler/sdk anymore #97

Closed dev-z closed 3 months ago

dev-z commented 3 months ago
maptiler-sdk-js version: https://github.com/maptiler/maptiler-sdk-js/releases/tag/v2.2.0

Bug Description:

LngLat is not available as a type to import from @maptiler/sdk anymore

// LngLat is not suggested as an import from maptiler SDK  and I have manually add it, hinting its not exported correctly 
import { LngLat } from "@maptiler/sdk";

function MyComponent() {
  const updateWeatherMetrics = (
    // IDE complains 'LngLat' refers to a value, but is being used as a type here. Did you mean 'typeof LngLat'?
    lngLat: LngLat,
    windLayer: WindLayer,
  ): void => {
    const windData = windLayer.pickAt(lngLat.lng, lngLat.lat);
    if (!windData) {
      setWindValue("");
    } else {
      const wValue = windData.speedMetersPerSecond.toFixed(1);
      const wUnit = "m/s";
      const wDirection = windData.compassDirection;
      setWindValue(`${wValue} ${wUnit} ${wDirection}`);
    }
  };

  return <></>;
}

new LngLat(0, 0) // works fine though

Problem

Types are not properly exported from the SDK.

Solution

It is fixed if there is a type LngLat = InstanceType<typeof LngLat>; being exported from maptiler SDK, like its previous versions.

jonathanlurie commented 3 months ago

Hello @dev-z , thanks for letting us know. I'll try to fix it asap

jonathanlurie commented 3 months ago

Hey @dev-z , thanks for your patience. the issue should be fixed with version v2.2.1 which is just pushed on NPM. Let me know if there are still any issues with type export.

dev-z commented 3 months ago

@jonathanlurie Works like a charm. Thank you.