deckgl-typings icon indicating copy to clipboard operation
deckgl-typings copied to clipboard

Type definition for tile is missing in the package

Open yudai-nkt opened this issue 4 years ago • 0 comments

I'm trying to annotate types for the following code, and IIUC deckgl-typings doesn't provide a proper type definition for the props parameter in TileLayer.renderSubLayers. This makes the related objects such as west or props.data inferred as any.

// example taken from deck.gl's repo
// https://github.com/visgl/deck.gl/blob/master/examples/website/map-tile/app.js
import { BitmapLayer } from "@deck.gl/layers";
import { TileLayer } from "@deck.gl/geo-layers";

//  I'm not sure if `undefined` is the correct type parameter for BitmapLayer here
const tileLayer: BitmapLayer<undefined> = new TileLayer({
  data: [
    'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
    'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png',
    'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png'
  ],

  renderSubLayers: (props) => {
    const {
      bbox: {west, south, east, north}
    } = props.tile;

    return new BitmapLayer(props, {
        data: undefined,
        image: props.data,
        bounds: [west, south, east, north]
      })
    ;
  }
});

I guess this props is something like a "tile" object (I don't know the right terminology) and type definition for such object is greatly appreciated.

I'm okay to submit a PR, but the problem is that I cannot find the specification of tiles in deck.gl documentation.

yudai-nkt avatar Mar 13 '21 13:03 yudai-nkt