Skip to content

fix(@angular/build): preserve diagnostic locations at offset 0 and guard empty files - #34415

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/compilation-diagnostics-offset-zero
Open

alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/compilation-diagnostics-offset-zero

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

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.

…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 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Oct 20, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review October 20, 2026 08:58
@alan-agius4
alan-agius4 requested review from clydin and dgp1130 and removed request for clydin October 20, 2026 08:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/angular/build/src/tools/angular/compilation/diagnostics.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant