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

add type definitions #113

Open
david-morris opened this issue May 17, 2024 · 0 comments
Open

add type definitions #113

david-morris opened this issue May 17, 2024 · 0 comments

Comments

@david-morris
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant