Skip to content

add type definitions #113

@david-morris

Description

@david-morris

Type definitions would be a quick-win to implement.

Here's what I've written so far (just enough for my use case):

declare module "@mapbox/mbtiles" {
  interface GetInfoCallbackResult {
    basename: string
    id: string
    filesize: number
    minzoom?: number
    maxzoom?: number
    center?: number[]
    bounds?: number[]
    scheme: string
    [key: string]: string | number | number[] | undefined
  }
  type GetTileCallback = (
    ...args:
      | [Error, undefined, undefined]
      | [null, Buffer, Record<string, string>]
  ) => void
  export default class MBTiles {
    constructor(
      uri: string,
      callback?: (error: Error, result: Record<string, string>) => void
    )
    getInfo(
      callback: (error: Error | null, info?: GetInfoCallbackResult) => void
    ): void
    getTile(z: number, x: number, y: number, callback: GetTileCallback): void
  }
}

Clearly that's not ready for prime-time yet, but I hope it inspires someone and helps them get started.

If someone else is using this library in typescript, comment this issue with anything you add to the types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions