Chevron DownAPI Reference

Using deck.gl with TypeScript

Starting from v8.8, deck.gl publishes "public preview" TypeScript types via an opt-in only entry point. To use the official types in your application, find the following statements:

import DeckGL from '@deck.gl/react';
import {GeoJsonLayer} from '@deck.gl/layers';

and replace the package name with @deck.gl/<module_name>/typed:

import DeckGL from '@deck.gl/react/typed';
import {GeoJsonLayer} from '@deck.gl/layers/typed';

You can also import additional type definitions:

import type {DeckGLRef} from '@deck.gl/react/typed';
import type {GeoJsonLayerProps} from '@deck.gl/layers/typed';

Note that the typed exports are a work in progress. They are not exposed by default to prevent any typing errors from breaking existing TypeScript applications. Help us improve them by reporting any issues or suggestions on GitHub!

The typed exports will remain at the typed entry points throughout the rest of the 8.x releases. They will be exposed directly at the package roots starting in v9.0.

Alternative Solution for Legacy Versions

If you are using a version before v8.8, a third-party typings library is available.

Find the compatible version of @danmarshall/deckgl-typings based on your deck.gl version:

deck.gl versiondeckgl-typings version
5.x.x1.x.x
6.x.x2.x.x
7.x.x3.x.x
8.x.x4.x.x

For example, for deck.gl 7.x, install the following package:

npm install @danmarshall/deckgl-typings@^3.0.0

Create a new file like deckgl.d.ts in your source directory with the following code:

import * as DeckTypings from "@danmarshall/deckgl-typings"
declare module "deck.gl" {
    export namespace DeckTypings {}
}