Skip to content

Commit

Permalink
polish: use nullish coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 31, 2022
1 parent b27a859 commit 656c25c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/babel-plugin-transform-classes/src/transformClass.ts
Expand Up @@ -516,7 +516,7 @@ export default function transformClass(
{ id: key, node: node, scope },
undefined,
supportUnicodeId,
) || fn;
) ?? fn;
}
} else {
// todo(flow->ts) find a way to avoid "key as t.StringLiteral" below which relies on this assignment
Expand Down Expand Up @@ -578,6 +578,7 @@ export default function transformClass(

const key = t.toComputedKey(node, node.key);
if (t.isStringLiteral(key)) {
// @ts-expect-error: requires strictNullCheck
func =
nameFunction(
{
Expand All @@ -587,7 +588,7 @@ export default function transformClass(
},
undefined,
supportUnicodeId,
) || func;
) ?? func;
}

const expr = t.expressionStatement(
Expand Down

0 comments on commit 656c25c

Please sign in to comment.