diff --git a/src/parser/plugins/typescript.ts b/src/parser/plugins/typescript.ts index 504e6750..d49f12f9 100644 --- a/src/parser/plugins/typescript.ts +++ b/src/parser/plugins/typescript.ts @@ -45,7 +45,6 @@ import { eatContextual, expect, expectContextual, - hasFollowingLineBreak, hasPrecedingLineBreak, isContextual, isLineTerminator, @@ -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 { diff --git a/src/parser/traverser/util.ts b/src/parser/traverser/util.ts index 5a72acae..2d481da1 100644 --- a/src/parser/traverser/util.ts +++ b/src/parser/traverser/util.ts @@ -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"; @@ -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(); }