Skip to content

Commit

Permalink
feat: Add Node.getSymbolOrThrow()
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Dec 10, 2017
1 parent c815955 commit 6abbe7f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/compiler/common/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ export class Node<NodeType extends ts.Node = ts.Node> {
}

/**
* Gets the compiler symbol.
* Gets the symbol or throws an error if it doesn't exist.
*/
getSymbolOrThrow(): Symbol {
return errors.throwIfNullOrUndefined(this.getSymbol(), "Could not find the node symbol.");
}

/**
* Gets the compiler symbol or undefined if it doesn't exist.
*/
getSymbol(): Symbol | undefined {
const boundSymbol = (this.compilerNode as any).symbol as ts.Symbol | undefined;
Expand Down

0 comments on commit 6abbe7f

Please sign in to comment.