Skip to content

Commit

Permalink
[compiler][fix] use the implemented nonNull utils to avoid duplicate …
Browse files Browse the repository at this point in the history
…code.
  • Loading branch information
arthur-mountain committed Oct 26, 2024
1 parent fe04dbc commit a5de97f
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type {NodePath} from '@babel/traverse';
import type * as t from '@babel/types';
import {CompilerError} from '../CompilerError';
import {getOrInsertDefault} from '../Utils/utils';
import {getOrInsertDefault, nonNull} from '../Utils/utils';
import {GeneratedSource} from './HIR';

type IdentifierInfo = {
Expand Down Expand Up @@ -158,7 +158,7 @@ function handleAssignment(
case 'ArrayPattern': {
const path = lvalPath as NodePath<t.ArrayPattern>;
for (const element of path.get('elements')) {
if (nonNull(element)) {
if (nonNull(element.node)) {
handleAssignment(currentFn, identifiers, element);
}
}
Expand Down Expand Up @@ -213,9 +213,3 @@ function handleAssignment(
}
}
}

function nonNull<T extends NonNullable<t.Node>>(
t: NodePath<T | null>,
): t is NodePath<T> {
return t.node != null;
}

0 comments on commit a5de97f

Please sign in to comment.