Skip to content

Commit

Permalink
Add hasFollowingLineBreak
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Feb 8, 2021
1 parent c6e4386 commit da8ce69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/babel-parser/src/parser/util.js
Expand Up @@ -90,8 +90,16 @@ export default class UtilParser extends Tokenizer {
);
}

hasPrecedingLineBreak(state: State = this.state): boolean {
return lineBreak.test(this.input.slice(state.lastTokEnd, state.start));
hasPrecedingLineBreak(): boolean {
return lineBreak.test(
this.input.slice(this.state.lastTokEnd, this.state.start),
);
}

hasFollowingLineBreak(): boolean {
return lineBreak.test(
this.input.slice(this.state.end, this.nextTokenStart()),
);
}

// TODO
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/src/plugins/typescript/index.js
Expand Up @@ -2861,7 +2861,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// To avoid
// abstract interface
// Foo {}
if (!this.hasPrecedingLineBreak(this.lookahead())) {
if (!this.hasFollowingLineBreak()) {
node.abstract = true;
this.raise(
node.start,
Expand Down

0 comments on commit da8ce69

Please sign in to comment.