Skip to content

Commit

Permalink
feature: ifStatement: VariableDeclaration: drop semicolons
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jan 19, 2024
1 parent fa700a3 commit 74221ae
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/printer/visitors/if-statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,23 @@ export const IfStatement = (path, printer, semantics) => {

indent();
print('if ');
print('__test');

const testPath = path.get('test');

if (testPath.isVariableDeclaration()) {
const first = testPath.get('declarations.0');
const id = first.get('id');
const init = first.get('init');

print(testPath.node.kind);
print(' ');
print(id);
print(' = ');
print(init);
} else {
print('__test');
}

print(' ');
print('__consequent');

Expand Down

0 comments on commit 74221ae

Please sign in to comment.