Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Non-Iterable Data, Data Accessor type inference, Extension props #232

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 44 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TypeScript declaration files for [deck.gl](https://deck.gl/#/documentation/)

This is a work in progress - see the [issues list](https://github.com/danmarshall/deckgl-typings/issues)

```
```bash
npm install @danmarshall/deckgl-typings
```

Expand All @@ -14,28 +14,58 @@ Then it is possible to link the mappings in your project so typescript can find

Create a new file like `deckgl.d.ts` (although it could be named anything ending in `.d.ts`) in your `src/` directory with the following code:

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

## Version mapping

| deck.gl version | deckgl-typings version |
| --------------- | ---------------------- |
| 5.x.x | 1.x.x |
| 6.x.x | 2.x.x |
| 7.x.x | 3.x.x |
| 8.x.x | 4.x.x |
| deck.gl version | deckgl-typings version | type inference |
| --------------- | ---------------------- | -------------- |
| 5.x.x | 1.x.x | N |
| 6.x.x | 2.x.x | N |
| 7.x.x | 3.x.x | N |
| 8.x.x | 4.x.x | N |
| 8.x.x | 5.x.x | Y |

## Upgrading to v5

### Automatic typing on data accessors

For data types `Array`, `Iterable`, `AsyncIterable`, and `Promise<Array | Iterable | AsyncIterable>`, accessors can now infer the type of the datum they operate on:

```typescript
new TextLayer({
data: [1],
getPosition(x) {
// <-- x is of type number because data is type number[]
return [x, 0];
},
});
```

For most use cases, simply removing the explicit types from the Layer constructors will allow type inference to determine the correct type of data and of data accessors.

### Non-iterable data

Typing now supports using data buffers directly:

```typescript
new TextLayer({
data: {
attributes: { getPosition: new Int8Array([1, 2, 3, 4]) },
length: 4,
},
});
```

## Known issues

These typings are now v4 which targets deck.gl v8. The following issues are changes to v8 from deck.gl v7 which have not been added to these typings:
These typings are now v5 which targets deck.gl v8. The following issues are changes to v8 from deck.gl v7 which have not been added to these typings:

- [ ] [It is now possible to replace a layer's accessors with binary data attributes.](https://github.com/uber/deck.gl/blob/master/docs/whats-new.md#better-binary-data-support)
- [ ] [GPU filtering for layers](https://github.com/uber/deck.gl/blob/master/docs/whats-new.md#gpu-data-filter-in-aggregation-layers) - Adds a [getFilterValue](https://github.com/uber/deck.gl/blob/master/docs/api-reference/extensions/data-filter-extension.md#getfiltervalue-function) to some layers.
- [ ] [Optional specifying the \_framebuffer prop of Deck.](https://github.com/uber/deck.gl/blob/master/docs/whats-new.md#other-new-features-and-improvements)
- [ ] [Pick a 3d surface point in the scene](https://github.com/uber/deck.gl/blob/master/docs/whats-new.md#other-new-features-and-improvements) by passing unproject3D: true to deck.pickObject or deck.pickMultipleObjects.
- [ ] ArcLayer supports drawing arcs between two 3D positions
Expand Down
Loading