Skip to content

Commit 0e10eb6

Browse files
authored
🤖 Merge PR DefinitelyTyped#73326 types/project-osrm__osrm: Fixed typo, added RouteStep.driving_side; types/osrm: Mirrored type fixes by @danciu
1 parent 4d5aa56 commit 0e10eb6

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

‎types/osrm/index.d.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ declare namespace OSRM {
142142
| "uturn"
143143
| "sharp right"
144144
| "right"
145-
| "slight rigth"
145+
| "slight right"
146146
| "straight"
147147
| "slight left"
148148
| "left"
@@ -443,8 +443,8 @@ declare namespace OSRM {
443443
* https://github.com/Project-OSRM/node-osrm/blob/master/docs/api.md#match
444444
*/
445445
interface MatchWaypoint extends Waypoint {
446-
matchings_index: number[];
447-
waypoint_index: number[];
446+
matchings_index: number;
447+
waypoint_index: number;
448448
}
449449

450450
/**

‎types/osrm/osrm-tests.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import * as fs from "fs";
22
import OSRM = require("osrm");
33

4-
// Access to Types from namespace
5-
const tile: OSRM.Tile = [0, 0, 0];
6-
const overview: OSRM.OverviewTypes = "full";
7-
84
// Version
95
OSRM.version;
106

@@ -136,6 +132,18 @@ osrm.match({ coordinates, timestamps, exclude }, (err, response) => {
136132
if (err) throw err;
137133
console.log(response.tracepoints); // array of Waypoint objects
138134
console.log(response.matchings); // array of Route objects
135+
136+
response.tracepoints.forEach((tracepoint) => {
137+
if (!tracepoint) {
138+
return;
139+
}
140+
141+
// $ExpectType number
142+
tracepoint.matchings_index;
143+
144+
// $ExpectType number
145+
tracepoint.waypoint_index;
146+
});
139147
});
140148

141149
osrm.match({ coordinates, timestamps, exclude }, { format: "object" }, (err, response) => {

‎types/project-osrm__osrm/index.d.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,14 @@ declare namespace OSRM {
142142
| "uturn"
143143
| "sharp right"
144144
| "right"
145-
| "slight rigth"
145+
| "slight right"
146146
| "straight"
147147
| "slight left"
148148
| "left"
149149
| "sharp left";
150+
type DrivingSide =
151+
| "left"
152+
| "right";
150153

151154
interface LineString {
152155
type: "LineString";
@@ -292,6 +295,10 @@ declare namespace OSRM {
292295
* The pronunciation hint of the rotary name. Optionally included, if the step is a rotary and a rotary pronunciation is available.
293296
*/
294297
rotary_pronunciation: string;
298+
/**
299+
* The legal driving side at the location for this step. Either left or right.
300+
*/
301+
driving_side: DrivingSide;
295302
}
296303

297304
/**

‎types/project-osrm__osrm/project-osrm__osrm-tests.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import * as fs from "fs";
22
import OSRM = require("@project-osrm/osrm");
3-
import assert from "assert";
4-
5-
// Access to Types from namespace
6-
const tile: OSRM.Tile = [0, 0, 0];
7-
const overview: OSRM.OverviewTypes = "full";
83

94
// Version
105
OSRM.version;
@@ -54,6 +49,19 @@ osrm.route({ coordinates, exclude }, (err, result) => {
5449
if (err) throw err;
5550
console.log(result.waypoints); // array of Waypoint objects representing all waypoints in order
5651
console.log(result.routes); // array of Route objects ordered by descending recommendation rank
52+
53+
const [firstRoute] = result.routes;
54+
const [firstLeg] = firstRoute.legs;
55+
const [firstStep] = firstLeg.steps;
56+
57+
// $ExpectType Route
58+
firstRoute;
59+
// $ExpectType RouteLeg
60+
firstLeg;
61+
// $ExpectType RouteStep
62+
firstStep;
63+
// $ExpectType DrivingSide
64+
firstStep.driving_side;
5765
});
5866

5967
osrm.route({ coordinates }, { format: "object" }, (err, result) => {

0 commit comments

Comments
 (0)