Skip to content

Commit

Permalink
Fix coverage by removing and documenting unnecessary line
Browse files Browse the repository at this point in the history
  • Loading branch information
alangpierce committed Jul 5, 2021
1 parent b31dbd9 commit a558e84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
7 changes: 3 additions & 4 deletions src/parser/plugins/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
eatContextual,
expect,
expectContextual,
hasFollowingLineBreak,
hasPrecedingLineBreak,
isContextual,
isLineTerminator,
Expand Down Expand Up @@ -1039,9 +1038,9 @@ function tsParseDeclaration(contextualKeyword: ContextualKeyword, isBeforeToken:

function tsCheckLineTerminator(isBeforeToken: boolean): boolean {
if (isBeforeToken) {
if (hasFollowingLineBreak()) {
return false;
}
// Babel checks hasFollowingLineBreak here and returns false, but this
// doesn't actually come up, e.g. `export interface` can never be on its own
// line in valid code.
next();
return true;
} else {
Expand Down
18 changes: 1 addition & 17 deletions src/parser/traverser/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {eat, finishToken, lookaheadTypeAndKeyword, match, nextTokenStart} from "../tokenizer/index";
import {eat, finishToken, lookaheadTypeAndKeyword, match} from "../tokenizer/index";
import type {ContextualKeyword} from "../tokenizer/keywords";
import {formatTokenType, TokenType, TokenType as tt} from "../tokenizer/types";
import {charCodes} from "../util/charcodes";
Expand Down Expand Up @@ -50,22 +50,6 @@ export function hasPrecedingLineBreak(): boolean {
return false;
}

export function hasFollowingLineBreak(): boolean {
const nextStart = nextTokenStart();
for (let i = state.end; i < nextStart; i++) {
const code = input.charCodeAt(i);
if (
code === charCodes.lineFeed ||
code === charCodes.carriageReturn ||
code === 0x2028 ||
code === 0x2029
) {
return true;
}
}
return false;
}

export function isLineTerminator(): boolean {
return eat(tt.semi) || canInsertSemicolon();
}
Expand Down

0 comments on commit a558e84

Please sign in to comment.