Skip to content

Commit b11b648

Browse files
authoredSep 15, 2022
Fix a crash (#161)
1 parent 81fe00d commit b11b648

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed
 

‎source/lib/parser.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,24 @@ export const extractAssertions = (program: Program): Map<Assertion, Set<CallExpr
2222
node.expression.name :
2323
node.expression;
2424

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

31-
const identifier = symbol.getName();
31+
const identifier = symbol.getName();
3232

33-
// Check if the call type is a valid assertion
34-
if (assertionFnNames.has(identifier)) {
35-
const assertion = identifier as Assertion;
33+
// Check if the call type is a valid assertion
34+
if (assertionFnNames.has(identifier)) {
35+
const assertion = identifier as Assertion;
3636

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

39-
nodes.add(node);
39+
nodes.add(node);
4040

41-
assertions.set(assertion, nodes);
41+
assertions.set(assertion, nodes);
42+
}
4243
}
4344
}
4445

0 commit comments

Comments
 (0)
Please sign in to comment.