Skip to content

Commit bce77fd

Browse files
authored
Merge pull request microsoft#18960 from Microsoft/builderHandlesChangeInResolution
Builder handles changes in resolution/references when file's contents dont change
2 parents d08770b + 142a88a commit bce77fd

5 files changed

Lines changed: 275 additions & 108 deletions

File tree

src/compiler/builder.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ namespace ts {
7373
*/
7474
onRemoveSourceFile(path: Path): void;
7575
/**
76-
* Called when sourceFile is changed
76+
* For all source files, either "onUpdateSourceFile" or "onUpdateSourceFileWithSameVersion" will be called.
77+
* If the builder is sure that the source file needs an update, "onUpdateSourceFile" will be called;
78+
* otherwise "onUpdateSourceFileWithSameVersion" will be called.
7779
*/
7880
onUpdateSourceFile(program: Program, sourceFile: SourceFile): void;
7981
/**
80-
* Called when source file has not changed but has some of the resolutions invalidated
81-
* If returned true, builder will mark the file as changed (noting that something associated with file has changed)
82+
* For all source files, either "onUpdateSourceFile" or "onUpdateSourceFileWithSameVersion" will be called.
83+
* If the builder is sure that the source file needs an update, "onUpdateSourceFile" will be called;
84+
* otherwise "onUpdateSourceFileWithSameVersion" will be called.
85+
* This function should return whether the source file should be marked as changed (meaning that something associated with file has changed, e.g. module resolution)
8286
*/
8387
onUpdateSourceFileWithSameVersion(program: Program, sourceFile: SourceFile): boolean;
8488
/**
@@ -161,8 +165,7 @@ namespace ts {
161165
existingInfo.version = sourceFile.version;
162166
emitHandler.onUpdateSourceFile(program, sourceFile);
163167
}
164-
else if (program.hasInvalidatedResolution(sourceFile.path) &&
165-
emitHandler.onUpdateSourceFileWithSameVersion(program, sourceFile)) {
168+
else if (emitHandler.onUpdateSourceFileWithSameVersion(program, sourceFile)) {
166169
registerChangedFile(sourceFile.path, sourceFile.fileName);
167170
}
168171
}

src/compiler/program.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,7 @@ namespace ts {
663663
dropDiagnosticsProducingTypeChecker,
664664
getSourceFileFromReference,
665665
sourceFileToPackageName,
666-
redirectTargetsSet,
667-
hasInvalidatedResolution
666+
redirectTargetsSet
668667
};
669668

670669
verifyCompilerOptions();

src/compiler/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,8 +2529,6 @@ namespace ts {
25292529
/* @internal */ sourceFileToPackageName: Map<string>;
25302530
/** Set of all source files that some other source file redirects to. */
25312531
/* @internal */ redirectTargetsSet: Map<true>;
2532-
/** Returns true when file in the program had invalidated resolution at the time of program creation. */
2533-
/* @internal */ hasInvalidatedResolution: HasInvalidatedResolution;
25342532
}
25352533

25362534
/* @internal */

0 commit comments

Comments
 (0)