Repository navigation
fix(@angular/build): preserve diagnostic locations at offset 0 and guard empty files - #34415
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.
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 pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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.