Fixed (Critical null pointer bug) in incremental builder #61807
Closed
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.
Summary
This PR addresses a critical null pointer issue in TypeScript's incremental compilation builder system and fixes property mapping inconsistencies in diagnostic conversion functions.
Issues Fixed
1. Critical Null Pointer Bug in Builder System
src/compiler/builder.tslines 643 and 2147state.affectedFilesIndexwas accessed with non-null assertion (!) despite being defined asnumber | undefinedin theBuilderProgramStateinterfaceaffectedFilesIndexis undefined during incremental builds??)2. Diagnostic Property Mapping Inconsistencies
src/compiler/builder.tslines 577 and 1507DiagnosticandReusableDiagnostictypes:DiagnostichasreportsDeprecatedpropertyReusableDiagnostichasreportDeprecatedpropertyconvertToDiagnostics:diagnostic.reportDeprecated→result.reportsDeprecatedtoReusableDiagnostic:diagnostic.reportsDeprecated→result.reportDeprecatedTechnical Details
The
affectedFilesIndextracks the current position when iterating through files affected by changes in incremental compilation. The interface correctly allows this to beundefined, but the implementation incorrectly assumed it was always defined.This bug could manifest during:
Code Changes
Risk Assessment
Low Risk: Changes only affect error-prone undefined access patterns and incorrect property mappings. The fixes make the code more robust and type-safe without changing core functionality.
Consideration
The following line
644Was commented as
TODO: GH#18217Testing Notes
hereby runtests) should be run to ensure no regressions