Repository navigation
Emit TS2734 for ASI errors involving nonstandard newlines - #65442
Closed
Sai krishna Bodapati (bodapatisaikrishna) wants to merge 1 commit into
Closed
Sai krishna Bodapati (bodapatisaikrishna) wants to merge 1 commit into
Sai krishna Bodapati (bodapatisaikrishna) wants to merge 1 commit into
Conversation
Copilot started reviewing on behalf of
Sai krishna Bodapati (bodapatisaikrishna)
November 11, 2026 15:55
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The shared regexp removes U+2028/U+2029 characters from existing type-annotation output, causing baseline comparisons to fail against unchanged references.
1 open issue
What changed in this PR
Fixes #65433 by restoring the TS2734 “Are you missing a semicolon?” hint for accidental calls across U+2028 and U+2029 line separators.
Changes:
- Recognizes Unicode line separators when skipping trivia and checking call boundaries.
- Aligns diagnostic baseline line splitting with ECMAScript line terminators.
- Adds scanner tests and compiler regression coverage with expected baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/betterErrorForAccidentalCallNonstandardLineBreak.ts |
Adds Unicode newline regression cases. |
tsc/testdata/baselines/reference/compiler/betterErrorForAccidentalCallNonstandardLineBreak.types |
Records expected type annotations. |
tsc/testdata/baselines/reference/compiler/betterErrorForAccidentalCallNonstandardLineBreak.symbols |
Records expected symbol annotations. |
tsc/testdata/baselines/reference/compiler/betterErrorForAccidentalCallNonstandardLineBreak.js |
Records expected JavaScript output. |
tsc/testdata/baselines/reference/compiler/betterErrorForAccidentalCallNonstandardLineBreak.errors.txt |
Records TS2349 errors with TS2734 hints. |
tsc/internal/testutil/tsbaseline/util.go |
Expands baseline line-delimiter recognition. |
tsc/internal/scanner/scanner.go |
Stops trivia scanning at Unicode line separators. |
tsc/internal/scanner/scanner_test.go |
Tests line-break stopping behavior. |
tsc/internal/checker/checker.go |
Decodes the preceding UTF-8 rune when detecting newlines. |
Review effort: Balanced
|
|
||
| var ( | ||
| lineDelimiter = regexp.MustCompile("\r?\n") | ||
| lineDelimiter = regexp.MustCompile("\r\n|[\n\r\u2028\u2029]") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #65433
Problem
Accidental call expressions across ECMAScript nonstandard line terminators (
U+2028Line Separator andU+2029Paragraph Separator), such asconst a = (x: number) => x\u2028(1), report TS2349 but fail to emit the related TS2734 ("Are you missing a semicolon?") diagnostic.Cause
Two factors:
scanner.SkipTriviaExonly handled'\r'and'\n'in its line break cases.0x2028and0x2029fell intodefault:which advanced past them without checkingoptions.StopAfterLineBreak.checker.gochecked the character preceding the skipped trivia via raw byte indexingtext[pos-1]. For multi-byte UTF-8 runes (0x2028and0x2029),text[pos-1]yielded only the trailing byte (0xA8/0xA9), which is not recognized as a line break. Additionally,tsbaseline/util.gosplit lines only on\r?\n, which went out of sync withComputeECMALineStarts.Change
case 0x2028, 0x2029:toSkipTriviaExto advance by rune size and stop whenoptions.StopAfterLineBreakis set.checker.go, decode the preceding rune withutf8.DecodeLastRuneInStringwhen inspecting trivia boundaries.tsbaseline.lineDelimiterto recognize ECMAScript line terminators\r\n|[\n\r\u2028\u2029].Testing
scanner_test.gocoveringSkipTriviaExline break stops across\r,\n,\r\n,\u2028,\u2029, trailing spaces, and comments.betterErrorForAccidentalCallNonstandardLineBreakcovering\u2028,\u2029, arrow expressions, declared functions, and trailing whitespace.This patch was written with AI assistance. I have read it, understand it, and will handle review myself.