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

TypeScript Definitions #265

Open
alexsantos-eth opened this issue Sep 29, 2020 · 1 comment
Open

TypeScript Definitions #265

alexsantos-eth opened this issue Sep 29, 2020 · 1 comment

Comments

@alexsantos-eth
Copy link

I dont found any typescript definition file for ApiResponse here.
maybe like this?

interface MapBoxDirections {
	code: string
	uuid: string
	waypoints: {
		distance: number
		name: string
		location: number[]
	}[]
	routes: {
		distance: number
		duration: number
		geometry: {
			coordinates: number[][]
			type: string
		}
		legs: {
			admins: {
				iso_3166_1: string
				iso_3166_1_alpha3: string
			}[]
			distance: number
			duration: number
			steps: []
			summary: string
			weight: number
		}[]
		weight: number
		weight_name: string
	}[]
}
@tobijafischer
Copy link

Thanks for sharing. I still couldn't find any types, so here's the slightly more up-to-date version of your type that I'm using.
The only difference really is that there is a new property legs.via_waypoints and that I have changed the location properties to [number, number] as coordinates are always returned in this format.

export interface MapboxDirections {
  code: string
  uuid: string
  waypoints: {
    distance: number
    name: string
    location: [number, number]
  }[]
  routes: {
    distance: number
    duration: number
    geometry: {
      coordinates: [number, number][]
      type: string
    }
    legs: {
      via_waypoints: [],
      admins: {
        iso_3166_1: string
        iso_3166_1_alpha3: string
      }[]
      distance: number
      duration: number
      steps: []
      summary: string
      weight: number
    }[]
    weight: number
    weight_name: string
  }[]
}

P.S. Note that legs.via_waypoints and legs.steps must be typed separately if these features are to be used.

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

2 participants