From 65a88019578b58d8e8a560cd0469a7f11a9a578c Mon Sep 17 00:00:00 2001 From: Teebo <1559534+tbo47@users.noreply.github.com> Date: Fri, 17 Nov 2023 01:41:08 -0800 Subject: [PATCH] tweak typescript integration (#30) --- src/dagre/position/bk.ts | 2 +- src/graphlib/graph.ts | 47 ++++++++++++++++++++-------------------- tsconfig.json | 1 + 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/dagre/position/bk.ts b/src/dagre/position/bk.ts index 3efea69..43fd33b 100644 --- a/src/dagre/position/bk.ts +++ b/src/dagre/position/bk.ts @@ -46,7 +46,7 @@ function findType1Conflicts(g, layering) { k0 = 0, // Tracks the last node in this layer scanned for crossings with a type-1 // segment. - scanPos = 0 as number | string, + scanPos: number | string = 0, prevLayerLength = prevLayer.length, lastNode = _.last(layer); diff --git a/src/graphlib/graph.ts b/src/graphlib/graph.ts index e614a7d..c10ad0e 100644 --- a/src/graphlib/graph.ts +++ b/src/graphlib/graph.ts @@ -24,23 +24,30 @@ var EDGE_KEY_DELIM = '\x01'; // edges up and, object properties, which have string keys, are the closest // we're going to get to a performant hashtable in JavaScript. export class Graph { - _isDirected: boolean; - _isMultigraph: boolean; - _isCompound: boolean; - _label: any; - _defaultNodeLabelFn: () => any; - _defaultEdgeLabelFn: () => any; - _nodes: {}; - _parent: {}; - _children: {}; - _in: {}; - _preds: {}; - _out: {}; - _sucs: {}; - _edgeObjs: {}; - _edgeLabels: {}; - _nodeCount = 0; - _edgeCount = 0; + protected _isDirected: boolean; + protected _isMultigraph: boolean; + protected _isCompound: boolean; + protected _label: any; + protected _defaultNodeLabelFn: () => any; + protected _defaultEdgeLabelFn: () => any; + protected _nodes: {}; + protected _parent: {}; + protected _children: {}; + protected _in: {}; + protected _preds: {}; + protected _out: {}; + protected _sucs: {}; + protected _edgeObjs: {}; + protected _edgeLabels: {}; + /** + * Number of nodes in the graph. Should only be changed by the implementation. + */ + protected _nodeCount = 0; + /** + * Number of edges in the graph. Should only be changed by the implementation. + */ + protected _edgeCount = 0; + constructor(opts = {} as { directed?: boolean, multigraph?: boolean, compound?: boolean }) { this._isDirected = _.has(opts, 'directed') ? opts.directed : true; this._isMultigraph = _.has(opts, 'multigraph') ? opts.multigraph : false; @@ -475,12 +482,6 @@ export class Graph { } } -/* Number of nodes in the graph. Should only be changed by the implementation. */ -Graph.prototype._nodeCount = 0; - -/* Number of edges in the graph. Should only be changed by the implementation. */ -Graph.prototype._edgeCount = 0; - function incrementOrInitEntry(map, k) { if (map[k]) { map[k]++; diff --git a/tsconfig.json b/tsconfig.json index 19182fb..f642166 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "target": "ES6", "outDir": "dist_tmp/", "types": [], + "module": "node16", }, "exclude": [ "src/**/*.test.ts",