deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

ViewStateProps Typescript object has missing type options for zoom

Open alexjbuck opened this issue 1 year ago • 0 comments

Description

If your View is an Orthographic View then the zoom can be a [number,number] type to denote independent x and y zoom values. In practice this works, however the ViewStateProps type is defined with zoom?: number so ts throws an type-checking error if you defined zoom = [1,1] for example, in a ViewStateProps object.

Type 'number[]' is not assignable to type 'number'

Minimal example to be used with an OrthographicView:

  const [viewState, setViewState] = useState<ViewStateProps>({
    maxZoom: 4,
    minZoom: -4,
    target: [0, 0],
    zoom: [0, 0],
  });

Flavors

  • [ ] Script tag
  • [X] React
  • [ ] Python/Jupyter notebook
  • [ ] MapboxOverlay
  • [ ] GoogleMapsOverlay
  • [ ] CartoLayer
  • [ ] ArcGIS

Expected Behavior

I expect to be able to provide either number or number[] to the zoom prop in a ViewStateProps object.

Steps to Reproduce

Minimal example to be used with an OrthographicView:

import { ViewStateProps } from "@deck.gl/core/lib/deck";

  const [viewState, setViewState] = useState<ViewStateProps>({
    maxZoom: 4,
    minZoom: -4,
    target: [0, 0],
    zoom: [0, 0],
  });

Environment

  • Framework version: "@deck.gl/core": "8.9.32",
  • Browser: Google Chrome
  • OS: MacOS 14.2.1
  • Editor: VS Code
  • Typescript 5.2.2

Logs

No response

alexjbuck avatar Feb 01 '24 04:02 alexjbuck