fix: check preceding line break before exclamation (#14049)

This commit is contained in:
Huáng Jùnliàng
2021-12-16 15:50:15 -05:00
committed by GitHub
parent 7178fbb008
commit ad17fe1cce
3 changed files with 61 additions and 1 deletions

View File

@@ -2832,7 +2832,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
kind: "var" | "let" | "const",
): void {
super.parseVarId(decl, kind);
if (decl.id.type === "Identifier" && this.eat(tt.bang)) {
if (
decl.id.type === "Identifier" &&
!this.hasPrecedingLineBreak() &&
this.eat(tt.bang)
) {
decl.definite = true;
}