Skip to content

Commit

Permalink
feat: TypeGuards.hasBody(node).
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Apr 7, 2018
1 parent 72afb28 commit 4041dfd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/utils/TypeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ export class TypeGuards {
return typeof (node as any).getName() === "string";
}

/**
* Gets if the node has a body.
* @param node - Node to check.
*/
static hasBody(node: compiler.Node): node is compiler.Node & { getBody(): compiler.Node; } {
// this method is manually maintained
if ((node as any).getBody == null)
return false;
return (node as any).getBody() != null;
}

/**
* Gets if the node is an AbstractableNode.
* @param node - Node to check.
Expand Down

0 comments on commit 4041dfd

Please sign in to comment.