Skip to content

Commit

Permalink
Fix a crash (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Sep 15, 2022
1 parent 81fe00d commit b11b648
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions source/lib/parser.ts
Expand Up @@ -22,23 +22,24 @@ export const extractAssertions = (program: Program): Map<Assertion, Set<CallExpr
node.expression.name :
node.expression;

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const maybeAlias = checker.getSymbolAtLocation(expression)!;
const symbol = maybeAlias.flags & SymbolFlags.Alias ?
checker.getAliasedSymbol(maybeAlias) :
maybeAlias;
const maybeAlias = checker.getSymbolAtLocation(expression);
if (maybeAlias) {
const symbol = maybeAlias.flags & SymbolFlags.Alias ?
checker.getAliasedSymbol(maybeAlias) :
maybeAlias;

const identifier = symbol.getName();
const identifier = symbol.getName();

// Check if the call type is a valid assertion
if (assertionFnNames.has(identifier)) {
const assertion = identifier as Assertion;
// Check if the call type is a valid assertion
if (assertionFnNames.has(identifier)) {
const assertion = identifier as Assertion;

const nodes = assertions.get(assertion) ?? new Set<CallExpression>();
const nodes = assertions.get(assertion) ?? new Set<CallExpression>();

nodes.add(node);
nodes.add(node);

assertions.set(assertion, nodes);
assertions.set(assertion, nodes);
}
}
}

Expand Down

0 comments on commit b11b648

Please sign in to comment.