From 532ab69256c0f6a207c32e1f63bad0a8bc3b3e66 Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Sun, 12 May 2019 15:15:21 +0100 Subject: [PATCH] feat(Typescript): Add generic data types for strongly typing nodes/links --- index.d.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index 13190ef..b67f871 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,25 +3,26 @@ // Definitions by: Nathan Westlake // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { Graph, Link, Node, NodeId } from "ngraph.graph" + declare module "ngraph.path" { - import { Graph, Link, Node, NodeId } from "ngraph.graph" - interface PathFinderOptions { + interface PathFinderOptions { oriented?: boolean quitFast?: boolean - heuristic?: (from: NodeId, to: NodeId) => number - distance?: (from: NodeId, to: NodeId, link: Link) => number + heuristic?: (from: Node, to: Node) => number + distance?: (from: Node, to: Node, link: Link) => number } - interface PathFinder { - find: (from: NodeId, to: NodeId) => Node[] + interface PathFinder { + find: (from: NodeId, to: NodeId) => Node[] } - export function aStar(graph: Graph, options?: PathFinderOptions): PathFinder + export function aStar(graph: Graph, options?: PathFinderOptions): PathFinder - export function aGreedy(graph: Graph, options?: PathFinderOptions): PathFinder + export function aGreedy(graph: Graph, options?: PathFinderOptions): PathFinder - export function nba(graph: Graph, options?: PathFinderOptions): PathFinder + export function nba(graph: Graph, options?: PathFinderOptions): PathFinder }