Skip to content

Commit 9740bcc

Browse files
authoredSep 23, 2022
Pluralized hasInvalidatedResolution -> hasInvalidatedResolutions (#50912)
* Pluralize hasInvalidatedResolution to hasInvalidatedResolutions. * Accepted baselines.
1 parent a455955 commit 9740bcc

13 files changed

+35
-35
lines changed
 

‎src/compiler/program.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ namespace ts {
748748
newOptions: CompilerOptions,
749749
getSourceVersion: (path: Path, fileName: string) => string | undefined,
750750
fileExists: (fileName: string) => boolean,
751-
hasInvalidatedResolution: HasInvalidatedResolution,
751+
hasInvalidatedResolutions: HasInvalidatedResolutions,
752752
hasChangedAutomaticTypeDirectiveNames: HasChangedAutomaticTypeDirectiveNames | undefined,
753753
getParsedCommandLine: (fileName: string) => ParsedCommandLine | undefined,
754754
projectReferences: readonly ProjectReference[] | undefined
@@ -782,7 +782,7 @@ namespace ts {
782782

783783
function sourceFileNotUptoDate(sourceFile: SourceFile) {
784784
return !sourceFileVersionUptoDate(sourceFile) ||
785-
hasInvalidatedResolution(sourceFile.path);
785+
hasInvalidatedResolutions(sourceFile.path);
786786
}
787787

788788
function sourceFileVersionUptoDate(sourceFile: SourceFile) {
@@ -1076,7 +1076,7 @@ namespace ts {
10761076
let moduleResolutionCache: ModuleResolutionCache | undefined;
10771077
let typeReferenceDirectiveResolutionCache: TypeReferenceDirectiveResolutionCache | undefined;
10781078
let actualResolveModuleNamesWorker: (moduleNames: string[], containingFile: SourceFile, containingFileName: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference) => ResolvedModuleFull[];
1079-
const hasInvalidatedResolution = host.hasInvalidatedResolution || returnFalse;
1079+
const hasInvalidatedResolutions = host.hasInvalidatedResolutions || returnFalse;
10801080
if (host.resolveModuleNames) {
10811081
actualResolveModuleNamesWorker = (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) => host.resolveModuleNames!(Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(resolved => {
10821082
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -1557,7 +1557,7 @@ namespace ts {
15571557
for (let i = 0; i < moduleNames.length; i++) {
15581558
const moduleName = moduleNames[i];
15591559
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
1560-
if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
1560+
if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
15611561
const oldResolvedModule = getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
15621562
if (oldResolvedModule) {
15631563
if (isTraceEnabled(options, host)) {
@@ -1822,7 +1822,7 @@ namespace ts {
18221822
// tentatively approve the file
18231823
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
18241824
}
1825-
else if (hasInvalidatedResolution(oldSourceFile.path)) {
1825+
else if (hasInvalidatedResolutions(oldSourceFile.path)) {
18261826
// 'module/types' references could have changed
18271827
structureIsReused = StructureIsReused.SafeModules;
18281828

‎src/compiler/resolutionCache.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ts {
1414
removeResolutionsOfFile(filePath: Path): void;
1515
removeResolutionsFromProjectReferenceRedirects(filePath: Path): void;
1616
setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: ESMap<Path, readonly string[]>): void;
17-
createHasInvalidatedResolution(customHasInvalidatedResolution: HasInvalidatedResolution): HasInvalidatedResolution;
17+
createHasInvalidatedResolutions(customHasInvalidatedResolutions: HasInvalidatedResolutions): HasInvalidatedResolutions;
1818
hasChangedAutomaticTypeDirectiveNames(): boolean;
1919
isFileWithInvalidatedNonRelativeUnresolvedImports(path: Path): boolean;
2020

@@ -236,7 +236,7 @@ namespace ts {
236236
invalidateResolutionOfFile,
237237
invalidateResolutionsOfFailedLookupLocations,
238238
setFilesWithInvalidatedNonRelativeUnresolvedImports,
239-
createHasInvalidatedResolution,
239+
createHasInvalidatedResolutions,
240240
isFileWithInvalidatedNonRelativeUnresolvedImports,
241241
updateTypeRootsWatch,
242242
closeTypeRootsWatch,
@@ -300,12 +300,12 @@ namespace ts {
300300
return !!value && !!value.length;
301301
}
302302

303-
function createHasInvalidatedResolution(customHasInvalidatedResolution: HasInvalidatedResolution): HasInvalidatedResolution {
303+
function createHasInvalidatedResolutions(customHasInvalidatedResolutions: HasInvalidatedResolutions): HasInvalidatedResolutions {
304304
// Ensure pending resolutions are applied
305305
invalidateResolutionsOfFailedLookupLocations();
306306
const collected = filesWithInvalidatedResolutions;
307307
filesWithInvalidatedResolutions = undefined;
308-
return path => customHasInvalidatedResolution(path) ||
308+
return path => customHasInvalidatedResolutions(path) ||
309309
!!collected?.has(path) ||
310310
isFileWithInvalidatedNonRelativeUnresolvedImports(path);
311311
}

‎src/compiler/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7179,7 +7179,7 @@ namespace ts {
71797179
}
71807180

71817181
/* @internal */
7182-
export type HasInvalidatedResolution = (sourceFile: Path) => boolean;
7182+
export type HasInvalidatedResolutions = (sourceFile: Path) => boolean;
71837183
/* @internal */
71847184
export type HasChangedAutomaticTypeDirectiveNames = () => boolean;
71857185

@@ -7216,7 +7216,7 @@ namespace ts {
72167216
/* @internal */ onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean): void;
72177217
/* @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void;
72187218
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
7219-
hasInvalidatedResolution?(filePath: Path): boolean;
7219+
hasInvalidatedResolutions?(filePath: Path): boolean;
72207220
/* @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames;
72217221
createHash?(data: string): string;
72227222
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;

‎src/compiler/watchPublic.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace ts {
113113
/** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
114114
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
115115
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
116-
hasInvalidatedResolution?(filePath: Path): boolean;
116+
hasInvalidatedResolutions?(filePath: Path): boolean;
117117
/**
118118
* Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
119119
*/
@@ -373,9 +373,9 @@ namespace ts {
373373
maybeBind(host, host.getModuleResolutionCache) :
374374
(() => resolutionCache.getModuleResolutionCache());
375375
const userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
376-
// All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolution
377-
const customHasInvalidatedResolution = userProvidedResolution ?
378-
maybeBind(host, host.hasInvalidatedResolution) || returnTrue :
376+
// All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions
377+
const customHasInvalidatedResolutions = userProvidedResolution ?
378+
maybeBind(host, host.hasInvalidatedResolutions) || returnTrue :
379379
returnFalse;
380380

381381
builderProgram = readBuilderProgram(compilerOptions, compilerHost) as any as T;
@@ -449,12 +449,12 @@ namespace ts {
449449
}
450450
}
451451

452-
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(customHasInvalidatedResolution);
452+
const hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
453453
const {
454454
originalReadFile, originalFileExists, originalDirectoryExists,
455455
originalCreateDirectory, originalWriteFile,
456456
} = changeCompilerHostLikeToUseCache(compilerHost, toPath);
457-
if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileName => compilerHost.fileExists(fileName), hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
457+
if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileName => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
458458
if (hasChangedConfigFileParsingErrors) {
459459
if (reportFileChangeDetectedOnCreateProgram) {
460460
reportWatchDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -467,7 +467,7 @@ namespace ts {
467467
if (reportFileChangeDetectedOnCreateProgram) {
468468
reportWatchDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation);
469469
}
470-
createNewProgram(hasInvalidatedResolution);
470+
createNewProgram(hasInvalidatedResolutions);
471471
}
472472

473473
reportFileChangeDetectedOnCreateProgram = false;
@@ -484,7 +484,7 @@ namespace ts {
484484
return builderProgram;
485485
}
486486

487-
function createNewProgram(hasInvalidatedResolution: HasInvalidatedResolution) {
487+
function createNewProgram(hasInvalidatedResolutions: HasInvalidatedResolutions) {
488488
// Compile the program
489489
writeLog("CreatingProgramWith::");
490490
writeLog(` roots: ${JSON.stringify(rootFileNames)}`);
@@ -495,7 +495,7 @@ namespace ts {
495495
hasChangedCompilerOptions = false;
496496
hasChangedConfigFileParsingErrors = false;
497497
resolutionCache.startCachingPerDirectoryResolution();
498-
compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
498+
compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
499499
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
500500
const oldProgram = getCurrentProgram();
501501
builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);

‎src/server/project.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ namespace ts.server {
172172
readonly realpath?: (path: string) => string;
173173

174174
/*@internal*/
175-
hasInvalidatedResolution: HasInvalidatedResolution | undefined;
175+
hasInvalidatedResolutions: HasInvalidatedResolutions | undefined;
176176

177177
/*@internal*/
178178
resolutionCache: ResolutionCache;
@@ -1176,7 +1176,7 @@ namespace ts.server {
11761176
Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
11771177
this.writeLog(`Starting updateGraphWorker: Project: ${this.getProjectName()}`);
11781178
const start = timestamp();
1179-
this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(returnFalse);
1179+
this.hasInvalidatedResolutions = this.resolutionCache.createHasInvalidatedResolutions(returnFalse);
11801180
this.resolutionCache.startCachingPerDirectoryResolution();
11811181
this.program = this.languageService.getProgram(); // TODO: GH#18217
11821182
this.dirty = false;

‎src/services/services.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ namespace ts {
13001300

13011301
// Get a fresh cache of the host information
13021302
const newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
1303-
const hasInvalidatedResolution: HasInvalidatedResolution = host.hasInvalidatedResolution || returnFalse;
1303+
const hasInvalidatedResolutions: HasInvalidatedResolutions = host.hasInvalidatedResolutions || returnFalse;
13041304
const hasChangedAutomaticTypeDirectiveNames = maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
13051305
const projectReferences = host.getProjectReferences?.();
13061306
let parsedCommandLines: ESMap<Path, ParsedCommandLine | false> | undefined;
@@ -1332,7 +1332,7 @@ namespace ts {
13321332
},
13331333
onReleaseOldSourceFile,
13341334
onReleaseParsedCommandLine,
1335-
hasInvalidatedResolution,
1335+
hasInvalidatedResolutions,
13361336
hasChangedAutomaticTypeDirectiveNames,
13371337
trace: maybeBind(host, host.trace),
13381338
resolveModuleNames: maybeBind(host, host.resolveModuleNames),
@@ -1369,7 +1369,7 @@ namespace ts {
13691369
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
13701370

13711371
// If the program is already up-to-date, we can reuse it
1372-
if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), fileName => compilerHost!.fileExists(fileName), hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
1372+
if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), fileName => compilerHost!.fileExists(fileName), hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
13731373
return;
13741374
}
13751375

‎src/services/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ namespace ts {
287287
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
288288
getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
289289
resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
290-
/* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution;
290+
/* @internal */ hasInvalidatedResolutions?: HasInvalidatedResolutions;
291291
/* @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames;
292292
/* @internal */ getGlobalTypingsCacheLocation?(): string | undefined;
293293
/* @internal */ getSymlinkCache?(files?: readonly SourceFile[]): SymlinkCache;

‎src/testRunner/unittests/reuseProgramStructure.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ namespace ts {
934934
return isProgramUptoDate(
935935
program, newRootFileNames, newOptions,
936936
path => program.getSourceFileByPath(path)!.version, /*fileExists*/ returnFalse,
937-
/*hasInvalidatedResolution*/ returnFalse,
937+
/*hasInvalidatedResolutions*/ returnFalse,
938938
/*hasChangedAutomaticTypeDirectiveNames*/ undefined,
939939
/*getParsedCommandLine*/ returnUndefined,
940940
/*projectReferences*/ undefined

‎src/testRunner/unittests/tscWatch/watchApi.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace ts.tscWatch {
5050
});
5151
});
5252

53-
describe("hasInvalidatedResolution", () => {
53+
describe("hasInvalidatedResolutions", () => {
5454
function verifyWatch(subScenario: string, implementHasInvalidatedResolution: boolean) {
5555
it(subScenario, () => {
5656
const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem({
@@ -70,7 +70,7 @@ namespace ts.tscWatch {
7070
host.resolveModuleNames = (moduleNames, containingFile, _reusedNames, _redirectedReference, options) =>
7171
moduleNames.map(m => resolveModuleName(m, containingFile, options, host).resolvedModule);
7272
// Invalidate resolutions only when ts file is created
73-
if (implementHasInvalidatedResolution) host.hasInvalidatedResolution = () => sys.fileExists(`${projectRoot}/other.ts`);
73+
if (implementHasInvalidatedResolution) host.hasInvalidatedResolutions = () => sys.fileExists(`${projectRoot}/other.ts`);
7474
const watch = createWatchProgram(host);
7575
runWatchBaseline({
7676
scenario: "watchApi",
@@ -104,8 +104,8 @@ namespace ts.tscWatch {
104104
});
105105
});
106106
}
107-
verifyWatch("host implements does not implement hasInvalidatedResolution", /*implementHasInvalidatedResolution*/ false);
108-
verifyWatch("host implements hasInvalidatedResolution", /*implementHasInvalidatedResolution*/ true);
107+
verifyWatch("host implements does not implement hasInvalidatedResolutions", /*implementHasInvalidatedResolution*/ false);
108+
verifyWatch("host implements hasInvalidatedResolutions", /*implementHasInvalidatedResolution*/ true);
109109
});
110110
});
111111

‎tests/baselines/reference/api/tsserverlibrary.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3321,7 +3321,7 @@ declare namespace ts {
33213321
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
33223322
getEnvironmentVariable?(name: string): string | undefined;
33233323
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
3324-
hasInvalidatedResolution?(filePath: Path): boolean;
3324+
hasInvalidatedResolutions?(filePath: Path): boolean;
33253325
createHash?(data: string): string;
33263326
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
33273327
}
@@ -5445,7 +5445,7 @@ declare namespace ts {
54455445
/** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
54465446
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
54475447
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
5448-
hasInvalidatedResolution?(filePath: Path): boolean;
5448+
hasInvalidatedResolutions?(filePath: Path): boolean;
54495449
/**
54505450
* Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
54515451
*/

0 commit comments

Comments
 (0)
Please sign in to comment.