Repository navigation
fix(@angular/build): preserve diagnostic locations at offset 0 and guard empty files - #34415
Open
alan-agius4 wants to merge 1 commit into
Open
alan-agius4 wants to merge 1 commit into
alan-agius4 wants to merge 1 commit into
Conversation
…ard empty files Ensure `convertTypeScriptDiagnosticInfo` checks `info.start !== undefined` so diagnostics and related information starting at file offset `0` retain their line, column, and lineText location properties. Also clamp `info.file.text.length - 1` to `0` when computing `lastLineOfFile` to prevent a TypeScript `Debug Failure` when reporting diagnostics on empty files.
alan-agius4
marked this pull request as ready for review
October 20, 2026 08:58
alan-agius4
requested review from
clydin and
dgp1130
and removed request for
clydin
October 20, 2026 08:58
There was a problem hiding this comment.
Code Review
This pull request improves TypeScript diagnostic conversion by correctly handling diagnostics that start at offset 0 (using an explicit undefined check) and preventing errors on empty files. It also introduces comprehensive unit tests for these cases. The feedback suggests simplifying the empty file handling by passing info.file.text.length directly to getLineAndCharacterOfPosition instead of using Math.max, as the file length is already a valid position in TypeScript.
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.
Ensure
convertTypeScriptDiagnosticInfochecksinfo.start !== undefinedso diagnostics and related information starting at file offset0retain theirline,column, andlineTextlocation properties. Also clampinfo.file.text.length - 1to0when computinglastLineOfFileto prevent a TypeScriptDebug Failurewhen reporting diagnostics on empty files.