Skip to content

Commit

Permalink
Less restrictive type restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
mesmo committed Aug 30, 2017
1 parent 53c4ea8 commit 5c474cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/node/tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export declare namespace Tree {
* @param node The node to return the ancestry for.
*/
function ancestors<TNode extends {
parent: TNode | undefined;
parent: any;
}>(node: TNode): Array<TNode>;
/**
* Returns the index of the lowest/least common ancestor given a pair of ancestrys.
Expand All @@ -31,7 +31,7 @@ export declare namespace Tree {
* @param parent The parent node.
*/
function isChild<TNode extends {
parent: TNode | undefined;
parent: any;
}>(child: TNode, parent: TNode): boolean;
/**
* Returns the depth (number of edges from a node to the root) of a node.
Expand All @@ -40,6 +40,6 @@ export declare namespace Tree {
* @returns The number of edges between the node an the root node. Returns -1 an undefined node is passed.
*/
function depth<TNode extends {
parent: TNode | undefined;
parent: any;
}>(node: TNode): number;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@steelbreeze/graph",
"version": "1.0.4",
"version": "1.0.5",
"description": "Graph libraries for TypeScript and JavaScript",
"main": "./lib/node/index.js",
"typings": "./lib/node/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export namespace Tree {
* @param TNode A common type shared by all node instances within the tree.
* @param node The node to return the ancestry for.
*/
export function ancestors<TNode extends { parent: TNode | undefined }>(node: TNode): Array<TNode> {
export function ancestors<TNode extends { parent: any }>(node: TNode): Array<TNode> {
const result: Array<TNode> = [];

for (let i: TNode | undefined = node; i !== undefined; i = i.parent) {
Expand Down Expand Up @@ -51,7 +51,7 @@ export namespace Tree {
* @param child The possible child node.
* @param parent The parent node.
*/
export function isChild<TNode extends { parent: TNode | undefined }>(child: TNode, parent: TNode): boolean {
export function isChild<TNode extends { parent: any }>(child: TNode, parent: TNode): boolean {
for (let i: TNode | undefined = child; i !== undefined; i = i.parent) {
if (i.parent === parent) {
return true;
Expand All @@ -67,7 +67,7 @@ export namespace Tree {
* @param child The node to get the depth of.
* @returns The number of edges between the node an the root node. Returns -1 an undefined node is passed.
*/
export function depth<TNode extends { parent: TNode | undefined }>(node: TNode): number {
export function depth<TNode extends { parent: any }>(node: TNode): number {
let result = -1;

for (let i: TNode | undefined = node; i !== undefined; i = i.parent) {
Expand Down

0 comments on commit 5c474cc

Please sign in to comment.