Use .append to force-commit semicolons for empty statements.
This commit is contained in:
parent
bd9bb053c3
commit
1bf76b0f33
@ -137,8 +137,7 @@ export let YieldExpression = buildYieldAwait("yield");
|
|||||||
export let AwaitExpression = buildYieldAwait("await");
|
export let AwaitExpression = buildYieldAwait("await");
|
||||||
|
|
||||||
export function EmptyStatement() {
|
export function EmptyStatement() {
|
||||||
this._lastPrintedIsEmptyStatement = true;
|
this.semicolon(true /* force */);
|
||||||
this.semicolon();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ExpressionStatement(node: Object) {
|
export function ExpressionStatement(node: Object) {
|
||||||
|
|||||||
@ -53,8 +53,8 @@ export default class Printer {
|
|||||||
* Add a semicolon to the buffer.
|
* Add a semicolon to the buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
semicolon(): void {
|
semicolon(force: boolean = false): void {
|
||||||
this._append(";", true /* queue */);
|
this._append(";", !force /* queue */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@ export default class Printer {
|
|||||||
rightBrace(): void {
|
rightBrace(): void {
|
||||||
if (!this.endsWith("\n")) this.newline();
|
if (!this.endsWith("\n")) this.newline();
|
||||||
|
|
||||||
if (this.format.minified && !this._lastPrintedIsEmptyStatement) {
|
if (this.format.minified) {
|
||||||
this._buf.removeLastSemicolon();
|
this._buf.removeLastSemicolon();
|
||||||
}
|
}
|
||||||
this.token("}");
|
this.token("}");
|
||||||
@ -262,8 +262,6 @@ export default class Printer {
|
|||||||
print(node, parent, opts = {}) {
|
print(node, parent, opts = {}) {
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
|
|
||||||
this._lastPrintedIsEmptyStatement = false;
|
|
||||||
|
|
||||||
if (parent && parent._compact) {
|
if (parent && parent._compact) {
|
||||||
node._compact = true;
|
node._compact = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user