Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): handle empty maybeAlias #161

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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