@typescript-deploys/pr-build 4.9.0-pr-50248-2 → 4.9.0-pr-50247-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +1783 -766
- package/lib/tsserver.js +1981 -907
- package/lib/tsserverlibrary.d.ts +39 -33
- package/lib/tsserverlibrary.js +1981 -907
- package/lib/typescript.d.ts +37 -30
- package/lib/typescript.js +1921 -856
- package/lib/typescriptServices.d.ts +37 -30
- package/lib/typescriptServices.js +1921 -856
- package/lib/typingsInstaller.js +1873 -812
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -4704,13 +4704,15 @@ var ts;
|
|
|
4704
4704
|
(function (FilePreprocessingDiagnosticsKind) {
|
|
4705
4705
|
FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingReferencedDiagnostic"] = 0] = "FilePreprocessingReferencedDiagnostic";
|
|
4706
4706
|
FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingFileExplainingDiagnostic"] = 1] = "FilePreprocessingFileExplainingDiagnostic";
|
|
4707
|
+
FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["ResolutionDiagnostics"] = 2] = "ResolutionDiagnostics";
|
|
4707
4708
|
})(FilePreprocessingDiagnosticsKind = ts.FilePreprocessingDiagnosticsKind || (ts.FilePreprocessingDiagnosticsKind = {}));
|
|
4708
4709
|
/* @internal */
|
|
4709
4710
|
var StructureIsReused;
|
|
4710
4711
|
(function (StructureIsReused) {
|
|
4711
4712
|
StructureIsReused[StructureIsReused["Not"] = 0] = "Not";
|
|
4712
|
-
StructureIsReused[StructureIsReused["
|
|
4713
|
-
StructureIsReused[StructureIsReused["
|
|
4713
|
+
StructureIsReused[StructureIsReused["SafeModuleCache"] = 1] = "SafeModuleCache";
|
|
4714
|
+
StructureIsReused[StructureIsReused["SafeModules"] = 2] = "SafeModules";
|
|
4715
|
+
StructureIsReused[StructureIsReused["Completely"] = 3] = "Completely";
|
|
4714
4716
|
})(StructureIsReused = ts.StructureIsReused || (ts.StructureIsReused = {}));
|
|
4715
4717
|
/** Return code used by getEmitOutput function to indicate status of the function */
|
|
4716
4718
|
var ExitStatus;
|
|
@@ -9469,6 +9471,8 @@ var ts;
|
|
|
9469
9471
|
Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
|
|
9470
9472
|
Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
|
|
9471
9473
|
Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
|
|
9474
|
+
Directory_0_resolves_to_1_scope_according_to_cache: diag(6263, ts.DiagnosticCategory.Message, "Directory_0_resolves_to_1_scope_according_to_cache_6263", "Directory '{0}' resolves to '{1}' scope according to cache."),
|
|
9475
|
+
Directory_0_has_no_containing_package_json_scope_according_to_cache: diag(6264, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_according_to_cache_6264", "Directory '{0}' has no containing package.json scope according to cache."),
|
|
9472
9476
|
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
9473
9477
|
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
9474
9478
|
Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, ts.DiagnosticCategory.Message, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
|
|
@@ -9652,6 +9656,7 @@ var ts;
|
|
|
9652
9656
|
Specify_how_the_TypeScript_watch_mode_works: diag(6715, ts.DiagnosticCategory.Message, "Specify_how_the_TypeScript_watch_mode_works_6715", "Specify how the TypeScript watch mode works."),
|
|
9653
9657
|
Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."),
|
|
9654
9658
|
Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
|
|
9659
|
+
Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation: diag(6719, ts.DiagnosticCategory.Message, "Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation_6719", "Save resolutions into .tsbuildinfo file and use them for incremental compilation."),
|
|
9655
9660
|
Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
|
|
9656
9661
|
one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
|
|
9657
9662
|
one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
|
|
@@ -14393,7 +14398,8 @@ var ts;
|
|
|
14393
14398
|
}
|
|
14394
14399
|
ts.changesAffectModuleResolution = changesAffectModuleResolution;
|
|
14395
14400
|
function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
|
|
14396
|
-
return
|
|
14401
|
+
return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
|
|
14402
|
+
optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
|
|
14397
14403
|
}
|
|
14398
14404
|
ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
|
|
14399
14405
|
function changesAffectingProgramStructure(oldOptions, newOptions) {
|
|
@@ -14471,21 +14477,20 @@ var ts;
|
|
|
14471
14477
|
}
|
|
14472
14478
|
ts.getFullWidth = getFullWidth;
|
|
14473
14479
|
function getResolvedModule(sourceFile, moduleNameText, mode) {
|
|
14474
|
-
|
|
14480
|
+
var _a, _b;
|
|
14481
|
+
return (_b = (_a = sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleNameText, mode)) === null || _b === void 0 ? void 0 : _b.resolvedModule;
|
|
14475
14482
|
}
|
|
14476
14483
|
ts.getResolvedModule = getResolvedModule;
|
|
14477
14484
|
function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
}
|
|
14485
|
+
var _a;
|
|
14486
|
+
(_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
|
|
14481
14487
|
sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
|
|
14482
14488
|
}
|
|
14483
14489
|
ts.setResolvedModule = setResolvedModule;
|
|
14484
|
-
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
|
|
14490
|
+
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
|
|
14491
|
+
var _a;
|
|
14492
|
+
(_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
|
|
14493
|
+
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
|
|
14489
14494
|
}
|
|
14490
14495
|
ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
|
|
14491
14496
|
function projectReferenceIsEqualTo(oldRef, newRef) {
|
|
@@ -14495,11 +14500,15 @@ var ts;
|
|
|
14495
14500
|
}
|
|
14496
14501
|
ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
|
|
14497
14502
|
function moduleResolutionIsEqualTo(oldResolution, newResolution) {
|
|
14498
|
-
return oldResolution
|
|
14499
|
-
oldResolution.
|
|
14500
|
-
oldResolution.
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
+
return oldResolution === newResolution ||
|
|
14504
|
+
oldResolution.resolvedModule === newResolution.resolvedModule ||
|
|
14505
|
+
!!oldResolution.resolvedModule &&
|
|
14506
|
+
!!newResolution.resolvedModule &&
|
|
14507
|
+
oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
|
|
14508
|
+
oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
|
|
14509
|
+
oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
|
|
14510
|
+
oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
|
|
14511
|
+
packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
|
|
14503
14512
|
}
|
|
14504
14513
|
ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
|
|
14505
14514
|
function packageIdIsEqual(a, b) {
|
|
@@ -14515,9 +14524,13 @@ var ts;
|
|
|
14515
14524
|
}
|
|
14516
14525
|
ts.packageIdToString = packageIdToString;
|
|
14517
14526
|
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
|
|
14518
|
-
return oldResolution
|
|
14519
|
-
|
|
14520
|
-
|
|
14527
|
+
return oldResolution === newResolution ||
|
|
14528
|
+
oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
|
|
14529
|
+
!!oldResolution.resolvedTypeReferenceDirective &&
|
|
14530
|
+
!!newResolution.resolvedTypeReferenceDirective &&
|
|
14531
|
+
oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
|
|
14532
|
+
!!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
|
|
14533
|
+
oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
|
|
14521
14534
|
}
|
|
14522
14535
|
ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
|
|
14523
14536
|
function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
|
|
@@ -19374,23 +19387,20 @@ var ts;
|
|
|
19374
19387
|
return getStringFromExpandedCharCodes(expandedCharCodes);
|
|
19375
19388
|
}
|
|
19376
19389
|
ts.base64decode = base64decode;
|
|
19377
|
-
function
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
|
|
19382
|
-
|
|
19383
|
-
|
|
19384
|
-
|
|
19385
|
-
|
|
19386
|
-
return result.config;
|
|
19387
|
-
}
|
|
19388
|
-
catch (e) {
|
|
19389
|
-
// gracefully handle if readFile fails or returns not JSON
|
|
19390
|
+
function readJsonIgnoringErrors(path, host) {
|
|
19391
|
+
return readJsonIgnoringErrorsFromText(path, host.readFile(path));
|
|
19392
|
+
}
|
|
19393
|
+
ts.readJsonIgnoringErrors = readJsonIgnoringErrors;
|
|
19394
|
+
function readJsonIgnoringErrorsFromText(path, jsonText) {
|
|
19395
|
+
if (!jsonText)
|
|
19396
|
+
return {};
|
|
19397
|
+
var result = ts.parseConfigFileTextToJson(path, jsonText);
|
|
19398
|
+
if (result.error) {
|
|
19390
19399
|
return {};
|
|
19391
19400
|
}
|
|
19401
|
+
return result.config;
|
|
19392
19402
|
}
|
|
19393
|
-
ts.
|
|
19403
|
+
ts.readJsonIgnoringErrorsFromText = readJsonIgnoringErrorsFromText;
|
|
19394
19404
|
function directoryProbablyExists(directoryName, host) {
|
|
19395
19405
|
// if host does not support 'directoryExists' assume that directory will exist
|
|
19396
19406
|
return !host.directoryExists || host.directoryExists(directoryName);
|
|
@@ -20472,14 +20482,15 @@ var ts;
|
|
|
20472
20482
|
},
|
|
20473
20483
|
setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
|
|
20474
20484
|
var _this = this;
|
|
20475
|
-
var _a;
|
|
20485
|
+
var _a, _b;
|
|
20476
20486
|
ts.Debug.assert(!hasProcessedResolutions);
|
|
20477
20487
|
hasProcessedResolutions = true;
|
|
20478
20488
|
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
20479
20489
|
var file = files_1[_i];
|
|
20480
|
-
(_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
|
|
20490
|
+
(_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution === null || resolution === void 0 ? void 0 : resolution.resolvedModule); });
|
|
20491
|
+
(_b = file.resolvedTypeReferenceDirectiveNames) === null || _b === void 0 ? void 0 : _b.forEach(function (resolution) { return processResolution(_this, resolution === null || resolution === void 0 ? void 0 : resolution.resolvedTypeReferenceDirective); });
|
|
20481
20492
|
}
|
|
20482
|
-
typeReferenceDirectives
|
|
20493
|
+
typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
|
|
20483
20494
|
},
|
|
20484
20495
|
hasProcessedResolutions: function () { return hasProcessedResolutions; },
|
|
20485
20496
|
};
|
|
@@ -39743,6 +39754,17 @@ var ts;
|
|
|
39743
39754
|
transpileOptionValue: undefined,
|
|
39744
39755
|
defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
|
|
39745
39756
|
},
|
|
39757
|
+
{
|
|
39758
|
+
name: "cacheResolutions",
|
|
39759
|
+
type: "boolean",
|
|
39760
|
+
category: ts.Diagnostics.Projects,
|
|
39761
|
+
description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
|
|
39762
|
+
affectsModuleResolution: true,
|
|
39763
|
+
affectsMultiFileEmitBuildInfo: true,
|
|
39764
|
+
affectsBundleEmitBuildInfo: true,
|
|
39765
|
+
transpileOptionValue: undefined,
|
|
39766
|
+
defaultValueDescription: false,
|
|
39767
|
+
},
|
|
39746
39768
|
{
|
|
39747
39769
|
name: "assumeChangesOnlyAffectDirectDependencies",
|
|
39748
39770
|
type: "boolean",
|
|
@@ -41840,6 +41862,9 @@ var ts;
|
|
|
41840
41862
|
if (result.configFilePath) {
|
|
41841
41863
|
result.configFilePath = toAbsolutePath(result.configFilePath);
|
|
41842
41864
|
}
|
|
41865
|
+
if (result.pathsBasePath) {
|
|
41866
|
+
result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
|
|
41867
|
+
}
|
|
41843
41868
|
return result;
|
|
41844
41869
|
}
|
|
41845
41870
|
ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
|
|
@@ -42825,20 +42850,36 @@ var ts;
|
|
|
42825
42850
|
ts.Debug.assert(ts.extensionIsTS(resolved.extension));
|
|
42826
42851
|
return { fileName: resolved.path, packageId: resolved.packageId };
|
|
42827
42852
|
}
|
|
42828
|
-
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
|
|
42829
|
-
var _a
|
|
42853
|
+
function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
|
|
42854
|
+
var _a;
|
|
42855
|
+
var _b;
|
|
42830
42856
|
if (resultFromCache) {
|
|
42831
|
-
(
|
|
42832
|
-
|
|
42857
|
+
if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
|
|
42858
|
+
(_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
|
|
42859
|
+
resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
|
|
42860
|
+
resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
|
|
42833
42861
|
return resultFromCache;
|
|
42834
42862
|
}
|
|
42835
42863
|
return {
|
|
42836
42864
|
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
|
|
42837
|
-
failedLookupLocations: failedLookupLocations,
|
|
42838
|
-
affectingLocations: affectingLocations,
|
|
42839
|
-
resolutionDiagnostics: diagnostics,
|
|
42865
|
+
failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
|
|
42866
|
+
affectingLocations: initializeResolutionField(affectingLocations),
|
|
42867
|
+
resolutionDiagnostics: initializeResolutionField(diagnostics),
|
|
42840
42868
|
};
|
|
42841
42869
|
}
|
|
42870
|
+
function initializeResolutionField(value) {
|
|
42871
|
+
return value.length ? value : undefined;
|
|
42872
|
+
}
|
|
42873
|
+
/*@internal*/
|
|
42874
|
+
function updateResolutionField(to, value) {
|
|
42875
|
+
if (!(value === null || value === void 0 ? void 0 : value.length))
|
|
42876
|
+
return to;
|
|
42877
|
+
if (!(to === null || to === void 0 ? void 0 : to.length))
|
|
42878
|
+
return value;
|
|
42879
|
+
to.push.apply(to, value);
|
|
42880
|
+
return to;
|
|
42881
|
+
}
|
|
42882
|
+
ts.updateResolutionField = updateResolutionField;
|
|
42842
42883
|
function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
|
|
42843
42884
|
if (!ts.hasProperty(jsonContent, fieldName)) {
|
|
42844
42885
|
if (state.traceEnabled) {
|
|
@@ -42990,8 +43031,7 @@ var ts;
|
|
|
42990
43031
|
options = redirectedReference.commandLine.options;
|
|
42991
43032
|
}
|
|
42992
43033
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
42993
|
-
var
|
|
42994
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
|
|
43034
|
+
var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, /*mode*/ resolutionMode, redirectedReference) : undefined;
|
|
42995
43035
|
if (result) {
|
|
42996
43036
|
if (traceEnabled) {
|
|
42997
43037
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -43049,7 +43089,7 @@ var ts;
|
|
|
43049
43089
|
features: features,
|
|
43050
43090
|
conditions: conditions,
|
|
43051
43091
|
requestContainingDirectory: containingDirectory,
|
|
43052
|
-
|
|
43092
|
+
reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
43053
43093
|
};
|
|
43054
43094
|
var resolved = primaryLookup();
|
|
43055
43095
|
var primary = true;
|
|
@@ -43069,8 +43109,15 @@ var ts;
|
|
|
43069
43109
|
isExternalLibraryImport: pathContainsNodeModules(fileName),
|
|
43070
43110
|
};
|
|
43071
43111
|
}
|
|
43072
|
-
result = {
|
|
43073
|
-
|
|
43112
|
+
result = {
|
|
43113
|
+
resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
|
|
43114
|
+
failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
|
|
43115
|
+
affectingLocations: initializeResolutionField(affectingLocations),
|
|
43116
|
+
resolutionDiagnostics: initializeResolutionField(diagnostics),
|
|
43117
|
+
};
|
|
43118
|
+
if (containingDirectory && cache) {
|
|
43119
|
+
cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
43120
|
+
}
|
|
43074
43121
|
if (traceEnabled)
|
|
43075
43122
|
traceResult(result);
|
|
43076
43123
|
return result;
|
|
@@ -43080,10 +43127,10 @@ var ts;
|
|
|
43080
43127
|
trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
|
|
43081
43128
|
}
|
|
43082
43129
|
else if (result.resolvedTypeReferenceDirective.packageId) {
|
|
43083
|
-
trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary);
|
|
43130
|
+
trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), !!result.resolvedTypeReferenceDirective.primary);
|
|
43084
43131
|
}
|
|
43085
43132
|
else {
|
|
43086
|
-
trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
|
|
43133
|
+
trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
|
|
43087
43134
|
}
|
|
43088
43135
|
}
|
|
43089
43136
|
function primaryLookup() {
|
|
@@ -43182,7 +43229,7 @@ var ts;
|
|
|
43182
43229
|
// `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types.
|
|
43183
43230
|
// See `createNotNeededPackageJSON` in the types-publisher` repo.
|
|
43184
43231
|
// eslint-disable-next-line no-null/no-null
|
|
43185
|
-
var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.
|
|
43232
|
+
var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJsonIgnoringErrors(packageJsonPath, host).typings === null;
|
|
43186
43233
|
if (!isNotNeededPackage) {
|
|
43187
43234
|
var baseFileName = ts.getBaseFileName(normalized);
|
|
43188
43235
|
// At this stage, skip results with leading dot.
|
|
@@ -43200,63 +43247,186 @@ var ts;
|
|
|
43200
43247
|
}
|
|
43201
43248
|
ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
|
|
43202
43249
|
/*@internal*/
|
|
43203
|
-
function
|
|
43204
|
-
|
|
43250
|
+
function getPackageJsconLocationFromScope(scope) {
|
|
43251
|
+
return ts.lastOrUndefined(scope.affectingLocations);
|
|
43252
|
+
}
|
|
43253
|
+
ts.getPackageJsconLocationFromScope = getPackageJsconLocationFromScope;
|
|
43254
|
+
function compilerOptionValueToString(value) {
|
|
43255
|
+
var _a;
|
|
43256
|
+
if (value === null || typeof value !== "object") { // eslint-disable-line no-null/no-null
|
|
43257
|
+
return "" + value;
|
|
43258
|
+
}
|
|
43259
|
+
if (ts.isArray(value)) {
|
|
43260
|
+
return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
|
|
43261
|
+
}
|
|
43262
|
+
var str = "{";
|
|
43263
|
+
for (var key in value) {
|
|
43264
|
+
if (ts.hasProperty(value, key)) {
|
|
43265
|
+
str += key + ": " + compilerOptionValueToString(value[key]);
|
|
43266
|
+
}
|
|
43267
|
+
}
|
|
43268
|
+
return str + "}";
|
|
43269
|
+
}
|
|
43270
|
+
/*@internal*/
|
|
43271
|
+
function getKeyForCompilationSettings(settings, options) {
|
|
43272
|
+
return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
|
|
43273
|
+
}
|
|
43274
|
+
ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
|
|
43275
|
+
/*@internal*/
|
|
43276
|
+
function getRedirectsCacheKey(options) {
|
|
43277
|
+
return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
|
|
43278
|
+
}
|
|
43279
|
+
ts.getRedirectsCacheKey = getRedirectsCacheKey;
|
|
43280
|
+
/*@internal*/
|
|
43281
|
+
function createCacheWithRedirects(ownOptions) {
|
|
43282
|
+
var ownMap;
|
|
43283
|
+
var ownKey;
|
|
43284
|
+
var redirectsKeyToCache = new ts.Map();
|
|
43205
43285
|
var redirectsMap = new ts.Map();
|
|
43206
43286
|
return {
|
|
43207
43287
|
getOwnMap: getOwnMap,
|
|
43208
|
-
|
|
43288
|
+
redirectsKeyToCache: redirectsKeyToCache,
|
|
43289
|
+
createMapForCompilerOptions: createMapForCompilerOptions,
|
|
43290
|
+
getMapOfCacheRedirects: getMapOfCacheRedirects,
|
|
43209
43291
|
getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
|
|
43210
43292
|
clear: clear,
|
|
43211
|
-
|
|
43212
|
-
|
|
43293
|
+
update: update,
|
|
43294
|
+
clearRedirectsMap: function () { return redirectsMap.clear(); },
|
|
43213
43295
|
};
|
|
43214
|
-
function
|
|
43215
|
-
|
|
43296
|
+
function ensureOwnKeyCached() {
|
|
43297
|
+
ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
|
|
43298
|
+
if (ownKey && !redirectsKeyToCache.has(ownKey))
|
|
43299
|
+
redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
|
|
43216
43300
|
}
|
|
43217
|
-
function
|
|
43218
|
-
options
|
|
43301
|
+
function createMapForCompilerOptions(options, optionsKey) {
|
|
43302
|
+
if (options === ownOptions)
|
|
43303
|
+
return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
|
|
43304
|
+
return getOrCreateRedirectMapAndKey(options, /*path*/ undefined, optionsKey);
|
|
43305
|
+
}
|
|
43306
|
+
function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
|
|
43307
|
+
var _a;
|
|
43308
|
+
if (path || options.configFile) {
|
|
43309
|
+
var redirects = redirectsMap.get(path || options.configFile.path);
|
|
43310
|
+
if (redirects)
|
|
43311
|
+
return redirects;
|
|
43312
|
+
}
|
|
43313
|
+
var key = optionsKey || getRedirectsCacheKey(options);
|
|
43314
|
+
var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
|
|
43315
|
+
if (!map) {
|
|
43316
|
+
ensureOwnKeyCached();
|
|
43317
|
+
if (ownKey === key) {
|
|
43318
|
+
map = ownMap;
|
|
43319
|
+
}
|
|
43320
|
+
else {
|
|
43321
|
+
redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
|
|
43322
|
+
}
|
|
43323
|
+
}
|
|
43324
|
+
if (path || options.configFile)
|
|
43325
|
+
redirectsMap.set(path || options.configFile.path, map);
|
|
43326
|
+
return map;
|
|
43219
43327
|
}
|
|
43220
|
-
function
|
|
43221
|
-
ownMap =
|
|
43328
|
+
function getOwnMap() {
|
|
43329
|
+
return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
|
|
43330
|
+
}
|
|
43331
|
+
function update(newOwnOptions) {
|
|
43332
|
+
// Store existing options:
|
|
43333
|
+
if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
|
|
43334
|
+
ensureOwnKeyCached();
|
|
43335
|
+
if (!redirectsMap.has(ownOptions.configFile.path)) {
|
|
43336
|
+
redirectsMap.set(ownOptions.configFile.path, ownMap);
|
|
43337
|
+
}
|
|
43338
|
+
}
|
|
43339
|
+
// If this is already present use it
|
|
43340
|
+
if (newOwnOptions.configFile) {
|
|
43341
|
+
var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
|
|
43342
|
+
if (existing_1) {
|
|
43343
|
+
ownMap = existing_1;
|
|
43344
|
+
ownOptions = newOwnOptions;
|
|
43345
|
+
return;
|
|
43346
|
+
}
|
|
43347
|
+
}
|
|
43348
|
+
var key = getRedirectsCacheKey(newOwnOptions);
|
|
43349
|
+
var existing = redirectsKeyToCache.get(key);
|
|
43350
|
+
ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
|
|
43351
|
+
ownKey = key;
|
|
43352
|
+
ownOptions = newOwnOptions;
|
|
43353
|
+
if (newOwnOptions.configFile)
|
|
43354
|
+
redirectsMap.set(newOwnOptions.configFile.path, ownMap);
|
|
43222
43355
|
}
|
|
43223
|
-
function
|
|
43224
|
-
if (!redirectedReference)
|
|
43356
|
+
function getMapOfCacheRedirects(redirectedReference) {
|
|
43357
|
+
if (!redirectedReference)
|
|
43358
|
+
return ownMap;
|
|
43359
|
+
var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
|
|
43360
|
+
if (directResult)
|
|
43361
|
+
return directResult;
|
|
43362
|
+
var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
|
|
43363
|
+
var fromKey = redirectsKeyToCache.get(key);
|
|
43364
|
+
if (fromKey) {
|
|
43365
|
+
redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
|
|
43366
|
+
return fromKey.map;
|
|
43367
|
+
}
|
|
43368
|
+
if (ownMap)
|
|
43369
|
+
ensureOwnKeyCached();
|
|
43370
|
+
if (ownKey === key) {
|
|
43371
|
+
redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
|
|
43225
43372
|
return ownMap;
|
|
43226
43373
|
}
|
|
43227
|
-
|
|
43228
|
-
|
|
43229
|
-
|
|
43230
|
-
|
|
43231
|
-
|
|
43232
|
-
|
|
43233
|
-
}
|
|
43234
|
-
return redirects;
|
|
43374
|
+
return undefined;
|
|
43375
|
+
}
|
|
43376
|
+
function getOrCreateMapOfCacheRedirects(redirectedReference) {
|
|
43377
|
+
return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
|
|
43378
|
+
getOwnMap() :
|
|
43379
|
+
getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, /*optionsKey*/ undefined);
|
|
43235
43380
|
}
|
|
43236
43381
|
function clear() {
|
|
43237
|
-
|
|
43382
|
+
ownKey = undefined;
|
|
43383
|
+
ownMap = undefined;
|
|
43238
43384
|
redirectsMap.clear();
|
|
43385
|
+
redirectsKeyToCache.clear();
|
|
43239
43386
|
}
|
|
43240
43387
|
}
|
|
43241
43388
|
ts.createCacheWithRedirects = createCacheWithRedirects;
|
|
43242
|
-
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
|
|
43243
|
-
var
|
|
43244
|
-
|
|
43389
|
+
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
|
|
43390
|
+
var dirToPackageJsonScope = new ts.Map();
|
|
43391
|
+
var oldPackageJsonInfoCache;
|
|
43392
|
+
return {
|
|
43393
|
+
getPackageJsonInfo: getPackageJsonInfo,
|
|
43394
|
+
setPackageJsonInfo: setPackageJsonInfo,
|
|
43395
|
+
clear: clear,
|
|
43396
|
+
entries: entries,
|
|
43397
|
+
getInternalMap: function () { return cache; },
|
|
43398
|
+
setInternalMap: function (value) { return cache = value; },
|
|
43399
|
+
clone: clone,
|
|
43400
|
+
getPackageJsonScope: getPackageJsonScope,
|
|
43401
|
+
setPackageJsonScope: setPackageJsonScope,
|
|
43402
|
+
setOldPackageJsonScopeCache: function (cache) { return oldPackageJsonInfoCache = cache; },
|
|
43403
|
+
};
|
|
43245
43404
|
function getPackageJsonInfo(packageJsonPath) {
|
|
43246
|
-
return cache === null || cache === void 0 ? void 0 : cache.get(
|
|
43405
|
+
return cache === null || cache === void 0 ? void 0 : cache.get(toPath(packageJsonPath));
|
|
43247
43406
|
}
|
|
43248
43407
|
function setPackageJsonInfo(packageJsonPath, info) {
|
|
43249
|
-
(cache || (cache = new ts.Map())).set(
|
|
43408
|
+
(cache || (cache = new ts.Map())).set(toPath(packageJsonPath), info);
|
|
43250
43409
|
}
|
|
43251
43410
|
function clear() {
|
|
43411
|
+
oldPackageJsonInfoCache = undefined;
|
|
43252
43412
|
cache = undefined;
|
|
43413
|
+
dirToPackageJsonScope.clear();
|
|
43253
43414
|
}
|
|
43254
43415
|
function entries() {
|
|
43255
43416
|
var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
|
|
43256
43417
|
return iter ? ts.arrayFrom(iter) : [];
|
|
43257
43418
|
}
|
|
43258
|
-
function
|
|
43259
|
-
return cache;
|
|
43419
|
+
function clone() {
|
|
43420
|
+
return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
|
|
43421
|
+
}
|
|
43422
|
+
function getPackageJsonScope(dir) {
|
|
43423
|
+
return dirToPackageJsonScope.get(dir) || (oldPackageJsonInfoCache === null || oldPackageJsonInfoCache === void 0 ? void 0 : oldPackageJsonInfoCache.getPackageJsonScope(dir));
|
|
43424
|
+
}
|
|
43425
|
+
function setPackageJsonScope(dir, scope) {
|
|
43426
|
+
moduleNameToDirectorySet(dirToPackageJsonScope, dir, scope, getPackageJsconLocationFromScope, toPath, ts.noop);
|
|
43427
|
+
}
|
|
43428
|
+
function toPath(file) {
|
|
43429
|
+
return ts.toPath(file, currentDirectory, getCanonicalFileName);
|
|
43260
43430
|
}
|
|
43261
43431
|
}
|
|
43262
43432
|
function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
|
|
@@ -43268,47 +43438,44 @@ var ts;
|
|
|
43268
43438
|
}
|
|
43269
43439
|
return result;
|
|
43270
43440
|
}
|
|
43271
|
-
function
|
|
43272
|
-
|
|
43273
|
-
|
|
43274
|
-
if (directoryToModuleNameMap.redirectsMap.size === 0) {
|
|
43275
|
-
// The own map will be for projectCompilerOptions
|
|
43276
|
-
ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
|
|
43277
|
-
ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
|
|
43278
|
-
ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
|
|
43279
|
-
directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
|
|
43280
|
-
moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
|
|
43281
|
-
}
|
|
43282
|
-
else {
|
|
43283
|
-
// Set correct own map
|
|
43284
|
-
ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
|
|
43285
|
-
var ref = {
|
|
43286
|
-
sourceFile: options.configFile,
|
|
43287
|
-
commandLine: { options: options }
|
|
43288
|
-
};
|
|
43289
|
-
directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
|
|
43290
|
-
moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
|
|
43291
|
-
}
|
|
43292
|
-
directoryToModuleNameMap.setOwnOptions(options);
|
|
43293
|
-
moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
|
|
43294
|
-
}
|
|
43295
|
-
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
|
|
43441
|
+
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
|
|
43442
|
+
var directoryToModuleNameMap = createCacheWithRedirects(options);
|
|
43443
|
+
var oldResolutionCache;
|
|
43296
43444
|
return {
|
|
43445
|
+
getFromCache: getFromCache,
|
|
43297
43446
|
getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
|
|
43298
43447
|
clear: clear,
|
|
43299
43448
|
update: update,
|
|
43449
|
+
setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
|
|
43300
43450
|
};
|
|
43301
43451
|
function clear() {
|
|
43452
|
+
oldResolutionCache = undefined;
|
|
43302
43453
|
directoryToModuleNameMap.clear();
|
|
43303
43454
|
}
|
|
43304
43455
|
function update(options) {
|
|
43305
|
-
|
|
43456
|
+
directoryToModuleNameMap.update(options);
|
|
43306
43457
|
}
|
|
43307
43458
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
43308
43459
|
var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
43309
|
-
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path,
|
|
43460
|
+
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
|
|
43461
|
+
}
|
|
43462
|
+
function getFromCache(directoryName, name, mode, redirectedReference) {
|
|
43463
|
+
var _a, _b;
|
|
43464
|
+
var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
43465
|
+
var result = (_b = (_a = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(path)) === null || _b === void 0 ? void 0 : _b.get(name, mode);
|
|
43466
|
+
if (result)
|
|
43467
|
+
return result;
|
|
43468
|
+
var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
|
|
43469
|
+
if (resultFromOld)
|
|
43470
|
+
getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
|
|
43471
|
+
return resultFromOld;
|
|
43310
43472
|
}
|
|
43311
43473
|
}
|
|
43474
|
+
/*@internal*/
|
|
43475
|
+
function getModeAwareCacheKey(specifier, mode) {
|
|
43476
|
+
return (mode === undefined ? specifier : mode + "|" + specifier);
|
|
43477
|
+
}
|
|
43478
|
+
ts.getModeAwareCacheKey = getModeAwareCacheKey;
|
|
43312
43479
|
/* @internal */
|
|
43313
43480
|
function createModeAwareCache() {
|
|
43314
43481
|
var underlying = new ts.Map();
|
|
@@ -43334,13 +43501,22 @@ var ts;
|
|
|
43334
43501
|
return cb(elem, specifier, mode);
|
|
43335
43502
|
});
|
|
43336
43503
|
},
|
|
43504
|
+
entries: function () {
|
|
43505
|
+
var keys = underlying.entries();
|
|
43506
|
+
return {
|
|
43507
|
+
next: function () {
|
|
43508
|
+
var next = keys.next();
|
|
43509
|
+
return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
|
|
43510
|
+
},
|
|
43511
|
+
};
|
|
43512
|
+
},
|
|
43337
43513
|
size: function () {
|
|
43338
43514
|
return underlying.size;
|
|
43339
|
-
}
|
|
43515
|
+
},
|
|
43340
43516
|
};
|
|
43341
43517
|
return cache;
|
|
43342
43518
|
function getUnderlyingCacheKey(specifier, mode) {
|
|
43343
|
-
var result =
|
|
43519
|
+
var result = getModeAwareCacheKey(specifier, mode);
|
|
43344
43520
|
memoizedReverseKeys.set(result, [specifier, mode]);
|
|
43345
43521
|
return result;
|
|
43346
43522
|
}
|
|
@@ -43353,38 +43529,120 @@ var ts;
|
|
|
43353
43529
|
for (var i = 0; i < keys.length; ++i) {
|
|
43354
43530
|
var entry = keys[i];
|
|
43355
43531
|
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
43356
|
-
var name = !ts.isString(entry) ? entry.fileName
|
|
43532
|
+
var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
|
|
43357
43533
|
var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
|
|
43358
43534
|
map.set(name, mode, values[i]);
|
|
43359
43535
|
}
|
|
43360
43536
|
return map;
|
|
43361
43537
|
}
|
|
43362
43538
|
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
43363
|
-
function
|
|
43364
|
-
var
|
|
43365
|
-
|
|
43539
|
+
function getCommonPrefix(directory, resolution, toPath) {
|
|
43540
|
+
var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
|
|
43541
|
+
// find first position where directory and resolution differs
|
|
43542
|
+
var i = 0;
|
|
43543
|
+
var limit = Math.min(directory.length, resolutionDirectory.length);
|
|
43544
|
+
while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
|
|
43545
|
+
i++;
|
|
43546
|
+
}
|
|
43547
|
+
if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
|
|
43548
|
+
return directory;
|
|
43549
|
+
}
|
|
43550
|
+
var rootLength = ts.getRootLength(directory);
|
|
43551
|
+
if (i < rootLength) {
|
|
43552
|
+
return undefined;
|
|
43553
|
+
}
|
|
43554
|
+
var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
|
|
43555
|
+
if (sep === -1) {
|
|
43556
|
+
return undefined;
|
|
43557
|
+
}
|
|
43558
|
+
return directory.substr(0, Math.max(sep, rootLength));
|
|
43559
|
+
}
|
|
43560
|
+
/*@internal*/
|
|
43561
|
+
function getResolvedFileNameForModuleNameToDirectorySet(result) {
|
|
43562
|
+
return result.resolvedModule &&
|
|
43563
|
+
(result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
|
|
43564
|
+
}
|
|
43565
|
+
ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
|
|
43566
|
+
/**
|
|
43567
|
+
* At first this function add entry directory -> module resolution result to the table.
|
|
43568
|
+
* Then it computes the set of parent folders for 'directory' that should have the same module resolution result
|
|
43569
|
+
* and for every parent folder in set it adds entry: parent -> module resolution. .
|
|
43570
|
+
* Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts.
|
|
43571
|
+
* Set of parent folders that should have the same result will be:
|
|
43572
|
+
* [
|
|
43573
|
+
* /a/b/c/d, /a/b/c, /a/b
|
|
43574
|
+
* ]
|
|
43575
|
+
* this means that request for module resolution from file in any of these folder will be immediately found in cache.
|
|
43576
|
+
*/
|
|
43577
|
+
/*@internal*/
|
|
43578
|
+
function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
|
|
43579
|
+
// if entry is already in cache do nothing
|
|
43580
|
+
if (directoryPathMap.has(directory))
|
|
43581
|
+
return;
|
|
43582
|
+
directoryPathMap.set(directory, result);
|
|
43583
|
+
var resolvedFileName = getResolvedFileName(result);
|
|
43584
|
+
// find common prefix between directory and resolved file name
|
|
43585
|
+
// this common prefix should be the shortest path that has the same resolution
|
|
43586
|
+
// directory: /a/b/c/d/e
|
|
43587
|
+
// resolvedFileName: /a/b/foo.d.ts
|
|
43588
|
+
// commonPrefix: /a/b
|
|
43589
|
+
// for failed lookups cache the result for every directory up to root
|
|
43590
|
+
var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
|
|
43591
|
+
var current = directory;
|
|
43592
|
+
while (current !== commonPrefix) {
|
|
43593
|
+
var parent = ts.getDirectoryPath(current);
|
|
43594
|
+
if (parent === current)
|
|
43595
|
+
break;
|
|
43596
|
+
if (directoryPathMap.has(parent)) {
|
|
43597
|
+
ancestoryWorker(parent);
|
|
43598
|
+
break;
|
|
43599
|
+
}
|
|
43600
|
+
directoryPathMap.set(parent, result);
|
|
43601
|
+
ancestoryWorker(parent);
|
|
43602
|
+
current = parent;
|
|
43603
|
+
}
|
|
43604
|
+
}
|
|
43605
|
+
ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
|
|
43606
|
+
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
|
|
43607
|
+
var moduleNameToDirectoryMap = createCacheWithRedirects(options);
|
|
43608
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
43366
43609
|
var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
43367
|
-
|
|
43610
|
+
var oldResolutionCache;
|
|
43611
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
|
|
43368
43612
|
function clear() {
|
|
43369
|
-
|
|
43370
|
-
packageJsonInfoCache.clear();
|
|
43371
|
-
}
|
|
43372
|
-
function clearAllExceptPackageJsonInfoCache() {
|
|
43613
|
+
oldResolutionCache = undefined;
|
|
43373
43614
|
perDirectoryResolutionCache.clear();
|
|
43374
43615
|
moduleNameToDirectoryMap.clear();
|
|
43616
|
+
packageJsonInfoCache.clear();
|
|
43375
43617
|
}
|
|
43376
43618
|
function update(options) {
|
|
43377
|
-
|
|
43619
|
+
perDirectoryResolutionCache.update(options);
|
|
43620
|
+
moduleNameToDirectoryMap.update(options);
|
|
43621
|
+
}
|
|
43622
|
+
function setOldResolutionCache(cache) {
|
|
43623
|
+
oldResolutionCache = cache;
|
|
43624
|
+
perDirectoryResolutionCache.setOldResolutionCache(cache);
|
|
43625
|
+
}
|
|
43626
|
+
function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
|
|
43627
|
+
var _a, _b;
|
|
43628
|
+
ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
|
|
43629
|
+
var result = (_b = (_a = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(getModeAwareCacheKey(nonRelativeModuleName, mode))) === null || _b === void 0 ? void 0 : _b.get(directoryName);
|
|
43630
|
+
if (result)
|
|
43631
|
+
return result;
|
|
43632
|
+
var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
|
|
43633
|
+
if (fromOld)
|
|
43634
|
+
getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
|
|
43635
|
+
return fromOld;
|
|
43378
43636
|
}
|
|
43379
43637
|
function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
|
|
43380
43638
|
ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
|
|
43381
|
-
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference,
|
|
43639
|
+
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
|
|
43382
43640
|
}
|
|
43383
43641
|
function createPerModuleNameCache() {
|
|
43384
43642
|
var directoryPathMap = new ts.Map();
|
|
43385
43643
|
return { get: get, set: set };
|
|
43386
43644
|
function get(directory) {
|
|
43387
|
-
return directoryPathMap.get(
|
|
43645
|
+
return directoryPathMap.get(toPath(directory));
|
|
43388
43646
|
}
|
|
43389
43647
|
/**
|
|
43390
43648
|
* At first this function add entry directory -> module resolution result to the table.
|
|
@@ -43398,74 +43656,27 @@ var ts;
|
|
|
43398
43656
|
* this means that request for module resolution from file in any of these folder will be immediately found in cache.
|
|
43399
43657
|
*/
|
|
43400
43658
|
function set(directory, result) {
|
|
43401
|
-
|
|
43402
|
-
// if entry is already in cache do nothing
|
|
43403
|
-
if (directoryPathMap.has(path)) {
|
|
43404
|
-
return;
|
|
43405
|
-
}
|
|
43406
|
-
directoryPathMap.set(path, result);
|
|
43407
|
-
var resolvedFileName = result.resolvedModule &&
|
|
43408
|
-
(result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
|
|
43409
|
-
// find common prefix between directory and resolved file name
|
|
43410
|
-
// this common prefix should be the shortest path that has the same resolution
|
|
43411
|
-
// directory: /a/b/c/d/e
|
|
43412
|
-
// resolvedFileName: /a/b/foo.d.ts
|
|
43413
|
-
// commonPrefix: /a/b
|
|
43414
|
-
// for failed lookups cache the result for every directory up to root
|
|
43415
|
-
var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
|
|
43416
|
-
var current = path;
|
|
43417
|
-
while (current !== commonPrefix) {
|
|
43418
|
-
var parent = ts.getDirectoryPath(current);
|
|
43419
|
-
if (parent === current || directoryPathMap.has(parent)) {
|
|
43420
|
-
break;
|
|
43421
|
-
}
|
|
43422
|
-
directoryPathMap.set(parent, result);
|
|
43423
|
-
current = parent;
|
|
43424
|
-
}
|
|
43425
|
-
}
|
|
43426
|
-
function getCommonPrefix(directory, resolution) {
|
|
43427
|
-
var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
|
|
43428
|
-
// find first position where directory and resolution differs
|
|
43429
|
-
var i = 0;
|
|
43430
|
-
var limit = Math.min(directory.length, resolutionDirectory.length);
|
|
43431
|
-
while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
|
|
43432
|
-
i++;
|
|
43433
|
-
}
|
|
43434
|
-
if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
|
|
43435
|
-
return directory;
|
|
43436
|
-
}
|
|
43437
|
-
var rootLength = ts.getRootLength(directory);
|
|
43438
|
-
if (i < rootLength) {
|
|
43439
|
-
return undefined;
|
|
43440
|
-
}
|
|
43441
|
-
var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
|
|
43442
|
-
if (sep === -1) {
|
|
43443
|
-
return undefined;
|
|
43444
|
-
}
|
|
43445
|
-
return directory.substr(0, Math.max(sep, rootLength));
|
|
43659
|
+
return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
|
|
43446
43660
|
}
|
|
43447
43661
|
}
|
|
43662
|
+
function toPath(fileName) {
|
|
43663
|
+
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
43664
|
+
}
|
|
43448
43665
|
}
|
|
43449
43666
|
ts.createModuleResolutionCache = createModuleResolutionCache;
|
|
43450
|
-
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache
|
|
43451
|
-
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName,
|
|
43667
|
+
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
|
|
43668
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
43452
43669
|
packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
|
|
43453
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear
|
|
43670
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear });
|
|
43454
43671
|
function clear() {
|
|
43455
|
-
clearAllExceptPackageJsonInfoCache();
|
|
43456
|
-
packageJsonInfoCache.clear();
|
|
43457
|
-
}
|
|
43458
|
-
function clearAllExceptPackageJsonInfoCache() {
|
|
43459
43672
|
perDirectoryResolutionCache.clear();
|
|
43673
|
+
packageJsonInfoCache.clear();
|
|
43460
43674
|
}
|
|
43461
43675
|
}
|
|
43462
43676
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
43463
43677
|
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
43464
43678
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
43465
|
-
|
|
43466
|
-
if (!perFolderCache)
|
|
43467
|
-
return undefined;
|
|
43468
|
-
return perFolderCache.get(moduleName, mode);
|
|
43679
|
+
return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
|
|
43469
43680
|
}
|
|
43470
43681
|
ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
|
|
43471
43682
|
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
@@ -43480,8 +43691,7 @@ var ts;
|
|
|
43480
43691
|
}
|
|
43481
43692
|
}
|
|
43482
43693
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
43483
|
-
var
|
|
43484
|
-
var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
|
|
43694
|
+
var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
|
|
43485
43695
|
if (result) {
|
|
43486
43696
|
if (traceEnabled) {
|
|
43487
43697
|
trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -43533,8 +43743,8 @@ var ts;
|
|
|
43533
43743
|
if (result && result.resolvedModule)
|
|
43534
43744
|
ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
|
|
43535
43745
|
ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
|
|
43536
|
-
if (
|
|
43537
|
-
|
|
43746
|
+
if (cache) {
|
|
43747
|
+
cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
|
|
43538
43748
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
43539
43749
|
// put result in per-module name cache
|
|
43540
43750
|
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
@@ -43820,10 +44030,10 @@ var ts;
|
|
|
43820
44030
|
features: features,
|
|
43821
44031
|
conditions: conditions,
|
|
43822
44032
|
requestContainingDirectory: containingDirectory,
|
|
43823
|
-
|
|
44033
|
+
reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
43824
44034
|
};
|
|
43825
44035
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43826
|
-
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
|
|
44036
|
+
return createResolvedModuleWithFailedLookupLocations(compilerOptions, (_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
|
|
43827
44037
|
function tryResolve(extensions) {
|
|
43828
44038
|
var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
|
|
43829
44039
|
var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
|
|
@@ -44200,25 +44410,47 @@ var ts;
|
|
|
44200
44410
|
features: NodeResolutionFeatures.None,
|
|
44201
44411
|
conditions: ts.emptyArray,
|
|
44202
44412
|
requestContainingDirectory: undefined,
|
|
44203
|
-
|
|
44413
|
+
reportResolutionDiagnostic: ts.noop
|
|
44204
44414
|
};
|
|
44205
44415
|
}
|
|
44206
44416
|
ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
|
|
44417
|
+
/*@internal*/
|
|
44418
|
+
function getPackageScope(dir, packageJsonInfoCache, host, options) {
|
|
44419
|
+
var state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
44420
|
+
var failedLookupLocations = [];
|
|
44421
|
+
var affectingLocations = [];
|
|
44422
|
+
state.failedLookupLocations = failedLookupLocations;
|
|
44423
|
+
state.affectingLocations = affectingLocations;
|
|
44424
|
+
var result = ts.forEachAncestorDirectory(dir, function (directory) {
|
|
44425
|
+
var _a;
|
|
44426
|
+
var fromCache = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonScope(directory);
|
|
44427
|
+
if (fromCache) {
|
|
44428
|
+
var host_1 = state.host, traceEnabled = state.traceEnabled;
|
|
44429
|
+
if (traceEnabled) {
|
|
44430
|
+
trace(host_1, fromCache.info ?
|
|
44431
|
+
ts.Diagnostics.Directory_0_resolves_to_1_scope_according_to_cache :
|
|
44432
|
+
ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_according_to_cache, directory, getPackageJsconLocationFromScope(fromCache));
|
|
44433
|
+
}
|
|
44434
|
+
return fromCache;
|
|
44435
|
+
}
|
|
44436
|
+
var info = getPackageJsonInfo(directory, /*onlyRecordFailures*/ false, state);
|
|
44437
|
+
if (info)
|
|
44438
|
+
return { info: info };
|
|
44439
|
+
}) || { info: undefined };
|
|
44440
|
+
result.failedLookupLocations = updateResolutionField(result.failedLookupLocations, !options.cacheResolutions || !result.info ? failedLookupLocations : undefined);
|
|
44441
|
+
result.affectingLocations = updateResolutionField(result.affectingLocations, affectingLocations);
|
|
44442
|
+
packageJsonInfoCache === null || packageJsonInfoCache === void 0 ? void 0 : packageJsonInfoCache.setPackageJsonScope(dir, result);
|
|
44443
|
+
return result;
|
|
44444
|
+
}
|
|
44445
|
+
ts.getPackageScope = getPackageScope;
|
|
44207
44446
|
/**
|
|
44208
|
-
* A function for locating the package.json scope
|
|
44447
|
+
* A function for locating the package.json scope in given directory path
|
|
44209
44448
|
*/
|
|
44210
44449
|
/*@internal*/
|
|
44211
|
-
function getPackageScopeForPath(
|
|
44212
|
-
|
|
44213
|
-
|
|
44214
|
-
|
|
44215
|
-
var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
|
|
44216
|
-
if (pkg) {
|
|
44217
|
-
return pkg;
|
|
44218
|
-
}
|
|
44219
|
-
parts.pop();
|
|
44220
|
-
}
|
|
44221
|
-
return undefined;
|
|
44450
|
+
function getPackageScopeForPath(dir, state) {
|
|
44451
|
+
return ts.forEachAncestorDirectory(dir, function (directory) {
|
|
44452
|
+
return getPackageJsonInfo(directory, /*onlyRecordFailures*/ false, state);
|
|
44453
|
+
});
|
|
44222
44454
|
}
|
|
44223
44455
|
ts.getPackageScopeForPath = getPackageScopeForPath;
|
|
44224
44456
|
/*@internal*/
|
|
@@ -44247,12 +44479,13 @@ var ts;
|
|
|
44247
44479
|
}
|
|
44248
44480
|
var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
|
|
44249
44481
|
if (directoryExists && host.fileExists(packageJsonPath)) {
|
|
44250
|
-
var
|
|
44482
|
+
var packageJsonText = host.readFile(packageJsonPath);
|
|
44483
|
+
var packageJsonContent = ts.readJsonIgnoringErrorsFromText(packageJsonPath, packageJsonText);
|
|
44251
44484
|
if (traceEnabled) {
|
|
44252
44485
|
trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
44253
44486
|
}
|
|
44254
44487
|
var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
|
|
44255
|
-
var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
|
|
44488
|
+
var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
|
|
44256
44489
|
(_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
|
|
44257
44490
|
state.affectingLocations.push(packageJsonPath);
|
|
44258
44491
|
return result;
|
|
@@ -44378,7 +44611,7 @@ var ts;
|
|
|
44378
44611
|
function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
44379
44612
|
var _a, _b;
|
|
44380
44613
|
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
44381
|
-
var directoryPath = ts.toPath(
|
|
44614
|
+
var directoryPath = ts.toPath(directory, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
|
|
44382
44615
|
var scope = getPackageScopeForPath(directoryPath, state);
|
|
44383
44616
|
if (!scope || !scope.packageJsonContent.exports) {
|
|
44384
44617
|
return undefined;
|
|
@@ -44437,7 +44670,7 @@ var ts;
|
|
|
44437
44670
|
return toSearchResult(/*value*/ undefined);
|
|
44438
44671
|
}
|
|
44439
44672
|
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
44440
|
-
var directoryPath = ts.toPath(
|
|
44673
|
+
var directoryPath = ts.toPath(directory, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
|
|
44441
44674
|
var scope = getPackageScopeForPath(directoryPath, state);
|
|
44442
44675
|
if (!scope) {
|
|
44443
44676
|
if (state.traceEnabled) {
|
|
@@ -44677,12 +44910,8 @@ var ts;
|
|
|
44677
44910
|
fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
|
|
44678
44911
|
}
|
|
44679
44912
|
}
|
|
44680
|
-
if (commonSourceDirGuesses.length > 1)
|
|
44681
|
-
state.
|
|
44682
|
-
? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
|
|
44683
|
-
: ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
|
|
44684
|
-
packagePath));
|
|
44685
|
-
}
|
|
44913
|
+
if (commonSourceDirGuesses.length > 1)
|
|
44914
|
+
state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
|
|
44686
44915
|
for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
|
|
44687
44916
|
var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
|
|
44688
44917
|
var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
|
|
@@ -44752,10 +44981,10 @@ var ts;
|
|
|
44752
44981
|
return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
44753
44982
|
}
|
|
44754
44983
|
function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
44755
|
-
var
|
|
44984
|
+
var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
44756
44985
|
return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
|
|
44757
44986
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
44758
|
-
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(
|
|
44987
|
+
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
|
|
44759
44988
|
if (resolutionFromCache) {
|
|
44760
44989
|
return resolutionFromCache;
|
|
44761
44990
|
}
|
|
@@ -44907,8 +45136,8 @@ var ts;
|
|
|
44907
45136
|
typesPackageName;
|
|
44908
45137
|
}
|
|
44909
45138
|
ts.unmangleScopedPackageName = unmangleScopedPackageName;
|
|
44910
|
-
function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
|
|
44911
|
-
var result = cache
|
|
45139
|
+
function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
|
|
45140
|
+
var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
|
|
44912
45141
|
if (result) {
|
|
44913
45142
|
if (state.traceEnabled) {
|
|
44914
45143
|
trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -44933,11 +45162,11 @@ var ts;
|
|
|
44933
45162
|
features: NodeResolutionFeatures.None,
|
|
44934
45163
|
conditions: [],
|
|
44935
45164
|
requestContainingDirectory: containingDirectory,
|
|
44936
|
-
|
|
45165
|
+
reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
44937
45166
|
};
|
|
44938
45167
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
44939
45168
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
44940
|
-
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value,
|
|
45169
|
+
return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value,
|
|
44941
45170
|
/*isExternalLibraryImport*/ false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
|
|
44942
45171
|
function tryResolve(extensions) {
|
|
44943
45172
|
var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
|
|
@@ -44945,10 +45174,9 @@ var ts;
|
|
|
44945
45174
|
return { value: resolvedUsingSettings };
|
|
44946
45175
|
}
|
|
44947
45176
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
44948
|
-
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
|
|
44949
45177
|
// Climb up parent directories looking for a module.
|
|
44950
45178
|
var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
|
|
44951
|
-
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(
|
|
45179
|
+
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, /*mode*/ undefined, directory, redirectedReference, state);
|
|
44952
45180
|
if (resolutionFromCache) {
|
|
44953
45181
|
return resolutionFromCache;
|
|
44954
45182
|
}
|
|
@@ -44993,10 +45221,10 @@ var ts;
|
|
|
44993
45221
|
features: NodeResolutionFeatures.None,
|
|
44994
45222
|
conditions: [],
|
|
44995
45223
|
requestContainingDirectory: undefined,
|
|
44996
|
-
|
|
45224
|
+
reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
44997
45225
|
};
|
|
44998
45226
|
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
44999
|
-
return createResolvedModuleWithFailedLookupLocations(resolved,
|
|
45227
|
+
return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved,
|
|
45000
45228
|
/*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
|
|
45001
45229
|
}
|
|
45002
45230
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
@@ -48703,9 +48931,10 @@ var ts;
|
|
|
48703
48931
|
host.getSourceFiles().forEach(function (sf) {
|
|
48704
48932
|
if (!sf.resolvedModules)
|
|
48705
48933
|
return;
|
|
48706
|
-
sf.resolvedModules.forEach(function (
|
|
48707
|
-
|
|
48708
|
-
|
|
48934
|
+
sf.resolvedModules.forEach(function (_a) {
|
|
48935
|
+
var resolvedModule = _a.resolvedModule;
|
|
48936
|
+
if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
|
|
48937
|
+
map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!map.get(resolvedModule.packageId.name));
|
|
48709
48938
|
});
|
|
48710
48939
|
});
|
|
48711
48940
|
return map;
|
|
@@ -51660,7 +51889,7 @@ var ts;
|
|
|
51660
51889
|
: undefined;
|
|
51661
51890
|
}
|
|
51662
51891
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
51663
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
51892
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
51664
51893
|
if (isForAugmentation === void 0) { isForAugmentation = false; }
|
|
51665
51894
|
if (ts.startsWith(moduleReference, "@types/")) {
|
|
51666
51895
|
var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
@@ -51711,7 +51940,7 @@ var ts;
|
|
|
51711
51940
|
var diagnosticDetails = void 0;
|
|
51712
51941
|
var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
|
|
51713
51942
|
if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
|
|
51714
|
-
var scope = currentSourceFile.packageJsonScope;
|
|
51943
|
+
var scope = (_h = currentSourceFile.packageJsonScope) === null || _h === void 0 ? void 0 : _h.info;
|
|
51715
51944
|
var targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : undefined;
|
|
51716
51945
|
if (scope && !scope.packageJsonContent.type) {
|
|
51717
51946
|
if (targetExt) {
|
|
@@ -51812,10 +52041,10 @@ var ts;
|
|
|
51812
52041
|
}
|
|
51813
52042
|
else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
51814
52043
|
var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
|
|
51815
|
-
var suggestedExt = (
|
|
52044
|
+
var suggestedExt = (_j = suggestedExtensions.find(function (_a) {
|
|
51816
52045
|
var actualExt = _a[0], _importExt = _a[1];
|
|
51817
52046
|
return host.fileExists(absoluteRef_1 + actualExt);
|
|
51818
|
-
})) === null ||
|
|
52047
|
+
})) === null || _j === void 0 ? void 0 : _j[1];
|
|
51819
52048
|
if (suggestedExt) {
|
|
51820
52049
|
error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
|
|
51821
52050
|
}
|
|
@@ -86853,9 +87082,9 @@ var ts;
|
|
|
86853
87082
|
var paramTag = node.parent.parent;
|
|
86854
87083
|
if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
|
|
86855
87084
|
// Else we will add a diagnostic, see `checkJSDocVariadicType`.
|
|
86856
|
-
var
|
|
87085
|
+
var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
|
|
86857
87086
|
var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent);
|
|
86858
|
-
if (
|
|
87087
|
+
if (host_2 || isCallbackTag) {
|
|
86859
87088
|
/*
|
|
86860
87089
|
Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters.
|
|
86861
87090
|
So in the following situation we will not create an array type:
|
|
@@ -86865,7 +87094,7 @@ var ts;
|
|
|
86865
87094
|
*/
|
|
86866
87095
|
var lastParamDeclaration = isCallbackTag
|
|
86867
87096
|
? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters)
|
|
86868
|
-
: ts.lastOrUndefined(
|
|
87097
|
+
: ts.lastOrUndefined(host_2.parameters);
|
|
86869
87098
|
var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
|
|
86870
87099
|
if (!lastParamDeclaration ||
|
|
86871
87100
|
symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
|
|
@@ -88290,11 +88519,12 @@ var ts;
|
|
|
88290
88519
|
if (resolvedTypeReferenceDirectives) {
|
|
88291
88520
|
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
|
88292
88521
|
fileToDirective = new ts.Map();
|
|
88293
|
-
resolvedTypeReferenceDirectives.forEach(function (
|
|
88294
|
-
|
|
88522
|
+
resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
|
|
88523
|
+
var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
|
|
88524
|
+
if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
|
|
88295
88525
|
return;
|
|
88296
88526
|
}
|
|
88297
|
-
var file = host.getSourceFile(
|
|
88527
|
+
var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
|
|
88298
88528
|
if (file) {
|
|
88299
88529
|
// Add the transitive closure of path references loaded by this file (as long as they are not)
|
|
88300
88530
|
// part of an existing type reference.
|
|
@@ -89650,9 +89880,9 @@ var ts;
|
|
|
89650
89880
|
}
|
|
89651
89881
|
var parent = ts.walkUpParenthesizedTypes(node.parent);
|
|
89652
89882
|
if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
|
|
89653
|
-
var
|
|
89654
|
-
if (
|
|
89655
|
-
parent = ts.getSingleVariableOfVariableStatement(
|
|
89883
|
+
var host_3 = ts.getJSDocHost(parent);
|
|
89884
|
+
if (host_3) {
|
|
89885
|
+
parent = ts.getSingleVariableOfVariableStatement(host_3) || host_3;
|
|
89656
89886
|
}
|
|
89657
89887
|
}
|
|
89658
89888
|
switch (parent.kind) {
|
|
@@ -111819,7 +112049,7 @@ var ts;
|
|
|
111819
112049
|
var sourceMap = sourceMapGenerator.toString();
|
|
111820
112050
|
ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
|
|
111821
112051
|
if (printer.bundleFileInfo)
|
|
111822
|
-
printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap,
|
|
112052
|
+
printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
|
|
111823
112053
|
}
|
|
111824
112054
|
}
|
|
111825
112055
|
else {
|
|
@@ -111831,7 +112061,7 @@ var ts;
|
|
|
111831
112061
|
// We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo
|
|
111832
112062
|
// This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode
|
|
111833
112063
|
if (printer.bundleFileInfo)
|
|
111834
|
-
printer.bundleFileInfo.hash = ts.computeSignature(text,
|
|
112064
|
+
printer.bundleFileInfo.hash = ts.computeSignature(text, host);
|
|
111835
112065
|
// Reset state
|
|
111836
112066
|
writer.clear();
|
|
111837
112067
|
}
|
|
@@ -111974,7 +112204,6 @@ var ts;
|
|
|
111974
112204
|
}
|
|
111975
112205
|
/*@internal*/
|
|
111976
112206
|
function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
|
|
111977
|
-
var createHash = ts.maybeBind(host, host.createHash);
|
|
111978
112207
|
var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
|
|
111979
112208
|
var buildInfo;
|
|
111980
112209
|
if (host.getBuildInfo) {
|
|
@@ -111996,25 +112225,25 @@ var ts;
|
|
|
111996
112225
|
if (!jsFileText)
|
|
111997
112226
|
return jsFilePath;
|
|
111998
112227
|
// If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
|
|
111999
|
-
if (ts.computeSignature(jsFileText,
|
|
112228
|
+
if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
|
|
112000
112229
|
return jsFilePath;
|
|
112001
112230
|
var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
|
|
112002
112231
|
// error if no source map or for now if inline sourcemap
|
|
112003
112232
|
if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
|
|
112004
112233
|
return sourceMapFilePath || "inline sourcemap decoding";
|
|
112005
|
-
if (sourceMapFilePath && ts.computeSignature(sourceMapText,
|
|
112234
|
+
if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
|
|
112006
112235
|
return sourceMapFilePath;
|
|
112007
112236
|
// read declaration text
|
|
112008
112237
|
var declarationText = declarationFilePath && host.readFile(declarationFilePath);
|
|
112009
112238
|
if (declarationFilePath && !declarationText)
|
|
112010
112239
|
return declarationFilePath;
|
|
112011
|
-
if (declarationFilePath && ts.computeSignature(declarationText,
|
|
112240
|
+
if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
|
|
112012
112241
|
return declarationFilePath;
|
|
112013
112242
|
var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
|
|
112014
112243
|
// error if no source map or for now if inline sourcemap
|
|
112015
112244
|
if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
|
|
112016
112245
|
return declarationMapPath || "inline sourcemap decoding";
|
|
112017
|
-
if (declarationMapPath && ts.computeSignature(declarationMapText,
|
|
112246
|
+
if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
|
|
112018
112247
|
return declarationMapPath;
|
|
112019
112248
|
var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
|
|
112020
112249
|
var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
|
|
@@ -112054,7 +112283,7 @@ var ts;
|
|
|
112054
112283
|
newBuildInfo.program = buildInfo.program;
|
|
112055
112284
|
if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
|
|
112056
112285
|
// Update the output signature
|
|
112057
|
-
newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText,
|
|
112286
|
+
newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
|
|
112058
112287
|
}
|
|
112059
112288
|
// Update sourceFileInfo
|
|
112060
112289
|
var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
|
|
@@ -112088,7 +112317,7 @@ var ts;
|
|
|
112088
112317
|
getSourceFileFromReference: ts.returnUndefined,
|
|
112089
112318
|
redirectTargetsMap: ts.createMultiMap(),
|
|
112090
112319
|
getFileIncludeReasons: ts.notImplemented,
|
|
112091
|
-
createHash: createHash,
|
|
112320
|
+
createHash: ts.maybeBind(host, host.createHash),
|
|
112092
112321
|
};
|
|
112093
112322
|
emitFiles(ts.notImplementedResolver, emitHost,
|
|
112094
112323
|
/*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
|
|
@@ -117584,7 +117813,7 @@ var ts;
|
|
|
117584
117813
|
var result = void 0;
|
|
117585
117814
|
var mode = getModeForFileReference(name, containingFileMode);
|
|
117586
117815
|
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
117587
|
-
var strName = ts.isString(name) ? name : name.fileName
|
|
117816
|
+
var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
|
|
117588
117817
|
var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
|
|
117589
117818
|
if (cache.has(cacheKey)) {
|
|
117590
117819
|
result = cache.get(cacheKey);
|
|
@@ -117688,8 +117917,22 @@ var ts;
|
|
|
117688
117917
|
return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
117689
117918
|
}
|
|
117690
117919
|
ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
|
|
117920
|
+
var emptyResolution = {
|
|
117921
|
+
resolvedModule: undefined,
|
|
117922
|
+
resolvedTypeReferenceDirective: undefined,
|
|
117923
|
+
failedLookupLocations: [],
|
|
117924
|
+
affectingLocations: [],
|
|
117925
|
+
resolutionDiagnostics: [],
|
|
117926
|
+
};
|
|
117927
|
+
function isResolvedModuleWithFailedLookupLocation(resolved) {
|
|
117928
|
+
return !!resolved && !!resolved.failedLookupLocations;
|
|
117929
|
+
}
|
|
117930
|
+
function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
|
|
117931
|
+
return !!resolved && !!resolved.failedLookupLocations;
|
|
117932
|
+
}
|
|
117691
117933
|
/* @internal */
|
|
117692
|
-
function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
|
|
117934
|
+
function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
|
|
117935
|
+
var _a;
|
|
117693
117936
|
if (names.length === 0) {
|
|
117694
117937
|
return [];
|
|
117695
117938
|
}
|
|
@@ -117699,7 +117942,7 @@ var ts;
|
|
|
117699
117942
|
for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
|
|
117700
117943
|
var name = names_3[_i];
|
|
117701
117944
|
var result = void 0;
|
|
117702
|
-
var mode = getModeForResolutionAtIndex(containingFile, i);
|
|
117945
|
+
var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
|
|
117703
117946
|
i++;
|
|
117704
117947
|
var cacheKey = mode !== undefined ? mode + "|" + name : name;
|
|
117705
117948
|
if (cache.has(cacheKey)) {
|
|
@@ -117764,14 +118007,14 @@ var ts;
|
|
|
117764
118007
|
/*@internal*/
|
|
117765
118008
|
function getReferencedFileLocation(getSourceFileByPath, ref) {
|
|
117766
118009
|
var _a, _b, _c;
|
|
117767
|
-
var _d, _e, _f, _g;
|
|
118010
|
+
var _d, _e, _f, _g, _h, _j;
|
|
117768
118011
|
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
117769
118012
|
var kind = ref.kind, index = ref.index;
|
|
117770
118013
|
var pos, end, packageId, resolutionMode;
|
|
117771
118014
|
switch (kind) {
|
|
117772
118015
|
case ts.FileIncludeKind.Import:
|
|
117773
118016
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
117774
|
-
packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) === null || _e === void 0 ? void 0 : _e.packageId;
|
|
118017
|
+
packageId = (_f = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) === null || _e === void 0 ? void 0 : _e.resolvedModule) === null || _f === void 0 ? void 0 : _f.packageId;
|
|
117775
118018
|
if (importLiteral.pos === -1)
|
|
117776
118019
|
return { file: file, packageId: packageId, text: importLiteral.text };
|
|
117777
118020
|
pos = ts.skipTrivia(file.text, importLiteral.pos);
|
|
@@ -117782,7 +118025,7 @@ var ts;
|
|
|
117782
118025
|
break;
|
|
117783
118026
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
117784
118027
|
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
|
|
117785
|
-
packageId = (
|
|
118028
|
+
packageId = (_j = (_h = (_g = file.resolvedTypeReferenceDirectiveNames) === null || _g === void 0 ? void 0 : _g.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _h === void 0 ? void 0 : _h.resolvedTypeReferenceDirective) === null || _j === void 0 ? void 0 : _j.packageId;
|
|
117786
118029
|
break;
|
|
117787
118030
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
117788
118031
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -117897,13 +118140,13 @@ var ts;
|
|
|
117897
118140
|
return undefined;
|
|
117898
118141
|
}
|
|
117899
118142
|
function lookupFromPackageJson() {
|
|
117900
|
-
var
|
|
117901
|
-
var
|
|
117902
|
-
|
|
117903
|
-
|
|
117904
|
-
|
|
117905
|
-
|
|
117906
|
-
|
|
118143
|
+
var _a;
|
|
118144
|
+
var packageJsonScope = ts.getPackageScope(ts.getDirectoryPath(fileName), packageJsonInfoCache, host, options);
|
|
118145
|
+
var impliedNodeFormat = ((_a = packageJsonScope.info) === null || _a === void 0 ? void 0 : _a.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
118146
|
+
return {
|
|
118147
|
+
impliedNodeFormat: impliedNodeFormat,
|
|
118148
|
+
packageJsonScope: packageJsonScope,
|
|
118149
|
+
};
|
|
117907
118150
|
}
|
|
117908
118151
|
}
|
|
117909
118152
|
ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
|
|
@@ -118023,10 +118266,10 @@ var ts;
|
|
|
118023
118266
|
};
|
|
118024
118267
|
}
|
|
118025
118268
|
function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
118026
|
-
var _a, _b, _c, _d;
|
|
118269
|
+
var _a, _b, _c, _d, _e;
|
|
118027
118270
|
var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
|
|
118028
118271
|
var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
|
|
118029
|
-
var
|
|
118272
|
+
var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
|
|
118030
118273
|
var processingDefaultLibFiles;
|
|
118031
118274
|
var processingOtherFiles;
|
|
118032
118275
|
var files;
|
|
@@ -118040,6 +118283,8 @@ var ts;
|
|
|
118040
118283
|
var cachedDeclarationDiagnosticsForFile = {};
|
|
118041
118284
|
var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
|
|
118042
118285
|
var fileProcessingDiagnostics;
|
|
118286
|
+
var automaticTypeDirectiveNames;
|
|
118287
|
+
var automaticTypeDirectiveResolutions;
|
|
118043
118288
|
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
|
118044
118289
|
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
|
118045
118290
|
// - For each root file, findSourceFile is called.
|
|
@@ -118061,6 +118306,11 @@ var ts;
|
|
|
118061
118306
|
var skipDefaultLib = options.noLib;
|
|
118062
118307
|
var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
|
|
118063
118308
|
var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
|
|
118309
|
+
/**
|
|
118310
|
+
* Diagnostics for the program
|
|
118311
|
+
* Only add diagnostics directly if it always would be done irrespective of program structure reuse.
|
|
118312
|
+
* Otherwise fileProcessingDiagnostics is correct locations so that the diagnostics can be reported in all structure use scenarios
|
|
118313
|
+
*/
|
|
118064
118314
|
var programDiagnostics = ts.createDiagnosticCollection();
|
|
118065
118315
|
var currentDirectory = host.getCurrentDirectory();
|
|
118066
118316
|
var supportedExtensions = ts.getSupportedExtensions(options);
|
|
@@ -118073,30 +118323,74 @@ var ts;
|
|
|
118073
118323
|
var actualResolveModuleNamesWorker;
|
|
118074
118324
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|
|
118075
118325
|
if (host.resolveModuleNames) {
|
|
118076
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName,
|
|
118077
|
-
|
|
118078
|
-
|
|
118079
|
-
|
|
118080
|
-
|
|
118081
|
-
|
|
118082
|
-
|
|
118083
|
-
|
|
118084
|
-
|
|
118326
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
|
|
118327
|
+
var _a;
|
|
118328
|
+
var result = host.resolveModuleNames(moduleNames, containingFileName, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
|
|
118329
|
+
var name = _a.name;
|
|
118330
|
+
return name;
|
|
118331
|
+
}), redirectedReference, options, containingFile, partialResolutionInfo);
|
|
118332
|
+
return result.some(isResolvedModuleWithFailedLookupLocation) ?
|
|
118333
|
+
result :
|
|
118334
|
+
result.map(function (resolved) { return resolved ?
|
|
118335
|
+
resolved.extension !== undefined ?
|
|
118336
|
+
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
|
118337
|
+
{ resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
|
|
118338
|
+
{ resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
|
|
118339
|
+
emptyResolution; });
|
|
118340
|
+
};
|
|
118085
118341
|
moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
118086
118342
|
}
|
|
118087
118343
|
else {
|
|
118088
118344
|
moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
118089
|
-
var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode)
|
|
118090
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName,
|
|
118345
|
+
var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
|
|
118346
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
|
|
118347
|
+
return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
|
|
118348
|
+
};
|
|
118091
118349
|
}
|
|
118092
118350
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
118093
118351
|
if (host.resolveTypeReferenceDirectives) {
|
|
118094
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode
|
|
118352
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
|
|
118353
|
+
var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
|
|
118354
|
+
return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
|
|
118355
|
+
result :
|
|
118356
|
+
result.map(function (resolved) { return resolved ?
|
|
118357
|
+
{ resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
|
|
118358
|
+
emptyResolution; });
|
|
118359
|
+
};
|
|
118360
|
+
typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
118095
118361
|
}
|
|
118096
118362
|
else {
|
|
118097
118363
|
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
118098
|
-
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode)
|
|
118099
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
118364
|
+
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
|
|
118365
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
118366
|
+
return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
|
|
118367
|
+
};
|
|
118368
|
+
}
|
|
118369
|
+
var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
|
|
118370
|
+
var oldBuildInfoProgram;
|
|
118371
|
+
if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
|
|
118372
|
+
var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
118373
|
+
oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
|
|
118374
|
+
fileExists: function (fileName) { return host.fileExists(fileName); },
|
|
118375
|
+
createHash: ts.maybeBind(host, host.createHash),
|
|
118376
|
+
getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), /*onlyRecordFailures*/ false, state_11); },
|
|
118377
|
+
});
|
|
118378
|
+
if (oldBuildInfoProgram) {
|
|
118379
|
+
// Ensure redirected references are verified before using existing cache
|
|
118380
|
+
moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
|
|
118381
|
+
getResolved: function (dirPath, name, mode, redirectedReference) {
|
|
118382
|
+
return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
|
|
118383
|
+
}
|
|
118384
|
+
});
|
|
118385
|
+
typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
|
|
118386
|
+
getResolved: function (dirPath, name, mode, redirectedReference) {
|
|
118387
|
+
return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
|
|
118388
|
+
}
|
|
118389
|
+
});
|
|
118390
|
+
moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache().setOldPackageJsonScopeCache({
|
|
118391
|
+
getPackageJsonScope: function (dirPath) { return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getPackageJsonScope(dirPath); }
|
|
118392
|
+
});
|
|
118393
|
+
}
|
|
118100
118394
|
}
|
|
118101
118395
|
// Map from a stringified PackageId to the source file with that id.
|
|
118102
118396
|
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
|
@@ -118123,9 +118417,9 @@ var ts;
|
|
|
118123
118417
|
var projectReferenceRedirects;
|
|
118124
118418
|
var mapFromFileToProjectReferenceRedirects;
|
|
118125
118419
|
var mapFromToProjectReferenceRedirectSource;
|
|
118126
|
-
var useSourceOfProjectReferenceRedirect = !!((
|
|
118420
|
+
var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
|
|
118127
118421
|
!options.disableSourceOfProjectReferenceRedirect;
|
|
118128
|
-
var
|
|
118422
|
+
var _f = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
118129
118423
|
compilerHost: host,
|
|
118130
118424
|
getSymlinkCache: getSymlinkCache,
|
|
118131
118425
|
useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
|
|
@@ -118133,7 +118427,7 @@ var ts;
|
|
|
118133
118427
|
getResolvedProjectReferences: getResolvedProjectReferences,
|
|
118134
118428
|
getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
|
|
118135
118429
|
forEachResolvedProjectReference: forEachResolvedProjectReference
|
|
118136
|
-
}), onProgramCreateComplete =
|
|
118430
|
+
}), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
|
|
118137
118431
|
var readFile = host.readFile.bind(host);
|
|
118138
118432
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
118139
118433
|
var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
@@ -118144,7 +118438,7 @@ var ts;
|
|
|
118144
118438
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
|
|
118145
118439
|
structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
|
|
118146
118440
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
118147
|
-
if (structureIsReused !==
|
|
118441
|
+
if (structureIsReused !== 3 /* Completely */) {
|
|
118148
118442
|
processingDefaultLibFiles = [];
|
|
118149
118443
|
processingOtherFiles = [];
|
|
118150
118444
|
if (projectReferences) {
|
|
@@ -118185,16 +118479,15 @@ var ts;
|
|
|
118185
118479
|
ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
|
|
118186
118480
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
118187
118481
|
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
|
|
118188
|
-
|
|
118189
|
-
|
|
118190
|
-
|
|
118191
|
-
|
|
118192
|
-
var
|
|
118193
|
-
var
|
|
118194
|
-
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
118195
|
-
for (var i = 0; i < typeReferences.length; i++) {
|
|
118482
|
+
automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
|
|
118483
|
+
automaticTypeDirectiveResolutions = ts.createModeAwareCache();
|
|
118484
|
+
if (automaticTypeDirectiveNames.length) {
|
|
118485
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: automaticTypeDirectiveNames.length });
|
|
118486
|
+
var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
|
|
118487
|
+
for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
|
|
118196
118488
|
// under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
|
|
118197
|
-
|
|
118489
|
+
automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], /*mode*/ undefined, resolutions[i]);
|
|
118490
|
+
processTypeReferenceDirective(automaticTypeDirectiveNames[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: automaticTypeDirectiveNames[i], packageId: (_d = resolutions[i].resolvedTypeReferenceDirective) === null || _d === void 0 ? void 0 : _d.packageId });
|
|
118198
118491
|
}
|
|
118199
118492
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
118200
118493
|
}
|
|
@@ -118234,13 +118527,13 @@ var ts;
|
|
|
118234
118527
|
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
|
|
118235
118528
|
// old file wasn't redirect but new file is
|
|
118236
118529
|
(oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
|
|
118237
|
-
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions()
|
|
118530
|
+
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
|
|
118238
118531
|
}
|
|
118239
118532
|
}
|
|
118240
118533
|
if (!host.getParsedCommandLine) {
|
|
118241
118534
|
oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
|
|
118242
118535
|
if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
|
|
118243
|
-
host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions()
|
|
118536
|
+
host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
|
|
118244
118537
|
}
|
|
118245
118538
|
});
|
|
118246
118539
|
}
|
|
@@ -118258,6 +118551,8 @@ var ts;
|
|
|
118258
118551
|
typeReferenceDirectiveResolutionCache = undefined;
|
|
118259
118552
|
// unconditionally set oldProgram to undefined to prevent it from being captured in closure
|
|
118260
118553
|
oldProgram = undefined;
|
|
118554
|
+
oldBuildInfoProgram = undefined;
|
|
118555
|
+
oldProgramOrOldBuildInfoProgramConstructor = undefined;
|
|
118261
118556
|
var program = {
|
|
118262
118557
|
getRootFileNames: function () { return rootNames; },
|
|
118263
118558
|
getSourceFile: getSourceFile,
|
|
@@ -118265,6 +118560,7 @@ var ts;
|
|
|
118265
118560
|
getSourceFiles: function () { return files; },
|
|
118266
118561
|
getMissingFilePaths: function () { return missingFilePaths; },
|
|
118267
118562
|
getModuleResolutionCache: function () { return moduleResolutionCache; },
|
|
118563
|
+
getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
|
|
118268
118564
|
getFilesByNameMap: function () { return filesByName; },
|
|
118269
118565
|
getCompilerOptions: function () { return options; },
|
|
118270
118566
|
getSyntacticDiagnostics: getSyntacticDiagnostics,
|
|
@@ -118289,6 +118585,9 @@ var ts;
|
|
|
118289
118585
|
getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
|
|
118290
118586
|
getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
|
|
118291
118587
|
getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
|
|
118588
|
+
getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
|
|
118589
|
+
getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
|
|
118590
|
+
getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
|
|
118292
118591
|
isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
|
|
118293
118592
|
isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
|
|
118294
118593
|
getSourceFileFromReference: getSourceFileFromReference,
|
|
@@ -118298,12 +118597,12 @@ var ts;
|
|
|
118298
118597
|
usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
|
|
118299
118598
|
isEmittedFile: isEmittedFile,
|
|
118300
118599
|
getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
|
|
118301
|
-
getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
|
|
118302
118600
|
getProjectReferences: getProjectReferences,
|
|
118303
118601
|
getResolvedProjectReferences: getResolvedProjectReferences,
|
|
118304
118602
|
getProjectReferenceRedirect: getProjectReferenceRedirect,
|
|
118305
118603
|
getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
|
|
118306
118604
|
getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
|
|
118605
|
+
getRedirectReferenceForResolution: getRedirectReferenceForResolution,
|
|
118307
118606
|
forEachResolvedProjectReference: forEachResolvedProjectReference,
|
|
118308
118607
|
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
|
|
118309
118608
|
emitBuildInfo: emitBuildInfo,
|
|
@@ -118311,7 +118610,7 @@ var ts;
|
|
|
118311
118610
|
readFile: readFile,
|
|
118312
118611
|
directoryExists: directoryExists,
|
|
118313
118612
|
getSymlinkCache: getSymlinkCache,
|
|
118314
|
-
realpath: (
|
|
118613
|
+
realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
|
|
118315
118614
|
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
|
|
118316
118615
|
getFileIncludeReasons: function () { return fileReasons; },
|
|
118317
118616
|
structureIsReused: structureIsReused,
|
|
@@ -118326,6 +118625,8 @@ var ts;
|
|
|
118326
118625
|
case 0 /* FilePreprocessingReferencedDiagnostic */:
|
|
118327
118626
|
var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
|
|
118328
118627
|
return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false)));
|
|
118628
|
+
case 2 /* ResolutionDiagnostics */:
|
|
118629
|
+
return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
|
|
118329
118630
|
default:
|
|
118330
118631
|
ts.Debug.assertNever(diagnostic);
|
|
118331
118632
|
}
|
|
@@ -118335,63 +118636,46 @@ var ts;
|
|
|
118335
118636
|
ts.performance.measure("Program", "beforeProgram", "afterProgram");
|
|
118336
118637
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
118337
118638
|
return program;
|
|
118338
|
-
function
|
|
118339
|
-
|
|
118340
|
-
|
|
118341
|
-
|
|
118342
|
-
var elem = list_3[_i];
|
|
118343
|
-
programDiagnostics.add(elem);
|
|
118344
|
-
}
|
|
118639
|
+
function getAutomaticTypeDirectiveContainingFile() {
|
|
118640
|
+
// This containingFilename needs to match with the one used in managed-side
|
|
118641
|
+
var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
|
|
118642
|
+
return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
118345
118643
|
}
|
|
118346
|
-
function
|
|
118347
|
-
|
|
118348
|
-
if (!moduleResolutionCache)
|
|
118644
|
+
function addResolutionDiagnostics(resolution) {
|
|
118645
|
+
if (!resolution.resolutionDiagnostics)
|
|
118349
118646
|
return;
|
|
118350
|
-
|
|
118351
|
-
|
|
118352
|
-
|
|
118353
|
-
|
|
118354
|
-
|
|
118355
|
-
|
|
118356
|
-
|
|
118357
|
-
// mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less
|
|
118358
|
-
var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
|
|
118359
|
-
var name = typeof n === "string" ? n : n.fileName;
|
|
118360
|
-
i++;
|
|
118361
|
-
// only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
|
|
118362
|
-
// (Since diagnostics are only issued via import or export map lookup)
|
|
118363
|
-
// This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
|
|
118364
|
-
// When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
|
|
118365
|
-
// APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
|
|
118366
|
-
if (ts.isExternalModuleNameRelative(name))
|
|
118367
|
-
continue;
|
|
118368
|
-
var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
|
|
118369
|
-
addResolutionDiagnostics(diags);
|
|
118370
|
-
}
|
|
118647
|
+
(fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
|
|
118648
|
+
kind: 2 /* ResolutionDiagnostics */,
|
|
118649
|
+
diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
|
|
118650
|
+
? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
|
|
118651
|
+
: ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, d.entry === "" ? "." : d.entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
|
|
118652
|
+
d.packagePath); })
|
|
118653
|
+
});
|
|
118371
118654
|
}
|
|
118372
|
-
function resolveModuleNamesWorker(moduleNames, containingFile,
|
|
118655
|
+
function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
|
|
118373
118656
|
if (!moduleNames.length)
|
|
118374
118657
|
return ts.emptyArray;
|
|
118375
118658
|
var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
|
118376
|
-
|
|
118659
|
+
if (redirectedReference === undefined)
|
|
118660
|
+
redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
118377
118661
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
|
|
118378
118662
|
ts.performance.mark("beforeResolveModule");
|
|
118379
|
-
var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName,
|
|
118663
|
+
var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
|
|
118380
118664
|
ts.performance.mark("afterResolveModule");
|
|
118381
118665
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
118382
118666
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
118383
|
-
pullDiagnosticsFromCache(moduleNames, containingFile);
|
|
118384
118667
|
return result;
|
|
118385
118668
|
}
|
|
118386
|
-
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
|
|
118669
|
+
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
|
|
118387
118670
|
if (!typeDirectiveNames.length)
|
|
118388
118671
|
return [];
|
|
118389
118672
|
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
118390
|
-
|
|
118673
|
+
if (redirectedReference === undefined && !ts.isString(containingFile))
|
|
118674
|
+
redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
118391
118675
|
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
118392
118676
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
|
|
118393
118677
|
ts.performance.mark("beforeResolveTypeReference");
|
|
118394
|
-
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
|
|
118678
|
+
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
|
|
118395
118679
|
ts.performance.mark("afterResolveTypeReference");
|
|
118396
118680
|
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
118397
118681
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -118444,9 +118728,6 @@ var ts;
|
|
|
118444
118728
|
}
|
|
118445
118729
|
return ts.libs.length + 2;
|
|
118446
118730
|
}
|
|
118447
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
|
|
118448
|
-
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
|
|
118449
|
-
}
|
|
118450
118731
|
function toPath(fileName) {
|
|
118451
118732
|
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
118452
118733
|
}
|
|
@@ -118471,10 +118752,11 @@ var ts;
|
|
|
118471
118752
|
return classifiableNames;
|
|
118472
118753
|
}
|
|
118473
118754
|
function resolveModuleNamesReusingOldState(moduleNames, file) {
|
|
118755
|
+
var _a;
|
|
118474
118756
|
if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
|
|
118475
118757
|
// If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
|
|
118476
118758
|
// the best we can do is fallback to the default logic.
|
|
118477
|
-
return resolveModuleNamesWorker(moduleNames, file, /*
|
|
118759
|
+
return resolveModuleNamesWorker(moduleNames, file, /*partialResolutionInfo*/ undefined, /*redirectedReference*/ undefined);
|
|
118478
118760
|
}
|
|
118479
118761
|
var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
|
|
118480
118762
|
if (oldSourceFile !== file && file.resolvedModules) {
|
|
@@ -118502,6 +118784,8 @@ var ts;
|
|
|
118502
118784
|
// With this information, we can infer some module resolutions without performing resolution.
|
|
118503
118785
|
/** An ordered list of module names for which we cannot recover the resolution. */
|
|
118504
118786
|
var unknownModuleNames;
|
|
118787
|
+
var unknownModuleNamesIndex;
|
|
118788
|
+
var reusedNames;
|
|
118505
118789
|
/**
|
|
118506
118790
|
* The indexing of elements in this list matches that of `moduleNames`.
|
|
118507
118791
|
*
|
|
@@ -118512,22 +118796,33 @@ var ts;
|
|
|
118512
118796
|
* * ResolvedModuleFull instance: can be reused.
|
|
118513
118797
|
*/
|
|
118514
118798
|
var result;
|
|
118515
|
-
var reusedNames;
|
|
118516
118799
|
/** A transient placeholder used to mark predicted resolution in the result list. */
|
|
118517
|
-
var predictedToResolveToAmbientModuleMarker =
|
|
118800
|
+
var predictedToResolveToAmbientModuleMarker = true;
|
|
118801
|
+
var redirectedReference;
|
|
118518
118802
|
for (var i = 0; i < moduleNames.length; i++) {
|
|
118519
118803
|
var moduleName = moduleNames[i];
|
|
118520
118804
|
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
|
|
118521
|
-
if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
|
|
118522
|
-
var
|
|
118523
|
-
|
|
118805
|
+
if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
|
|
118806
|
+
var mode = getModeForResolutionAtIndex(file, i);
|
|
118807
|
+
var oldResolution = !oldBuildInfoProgram ?
|
|
118808
|
+
(_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
|
|
118809
|
+
oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
|
|
118810
|
+
if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
|
|
118524
118811
|
if (ts.isTraceEnabled(options, host)) {
|
|
118525
|
-
ts.
|
|
118526
|
-
|
|
118527
|
-
ts.
|
|
118812
|
+
var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
|
|
118813
|
+
if (!oldBuildInfoProgram) {
|
|
118814
|
+
ts.trace(host, oldResolution.resolvedModule.packageId ?
|
|
118815
|
+
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
|
|
118816
|
+
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, fileLocation, oldResolution.resolvedModule.resolvedFileName, oldResolution.resolvedModule.packageId && ts.packageIdToString(oldResolution.resolvedModule.packageId));
|
|
118817
|
+
}
|
|
118818
|
+
else {
|
|
118819
|
+
ts.trace(host, oldResolution.resolvedModule.packageId ?
|
|
118820
|
+
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
|
|
118821
|
+
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3, moduleName, fileLocation, ts.getDirectoryPath(fileLocation), oldResolution.resolvedModule.resolvedFileName, oldResolution.resolvedModule.packageId && ts.packageIdToString(oldResolution.resolvedModule.packageId));
|
|
118822
|
+
}
|
|
118528
118823
|
}
|
|
118529
|
-
(result
|
|
118530
|
-
(reusedNames
|
|
118824
|
+
(result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
|
|
118825
|
+
(reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
|
|
118531
118826
|
continue;
|
|
118532
118827
|
}
|
|
118533
118828
|
}
|
|
@@ -118546,15 +118841,16 @@ var ts;
|
|
|
118546
118841
|
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
|
|
118547
118842
|
}
|
|
118548
118843
|
if (resolvesToAmbientModuleInNonModifiedFile) {
|
|
118549
|
-
(result
|
|
118844
|
+
(result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
|
|
118550
118845
|
}
|
|
118551
118846
|
else {
|
|
118552
118847
|
// Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
|
|
118553
|
-
(unknownModuleNames
|
|
118848
|
+
(unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
|
|
118849
|
+
(unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
|
|
118554
118850
|
}
|
|
118555
118851
|
}
|
|
118556
118852
|
var resolutions = unknownModuleNames && unknownModuleNames.length
|
|
118557
|
-
? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
|
|
118853
|
+
? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
|
|
118558
118854
|
: ts.emptyArray;
|
|
118559
118855
|
// Combine results of resolutions and predicted results
|
|
118560
118856
|
if (!result) {
|
|
@@ -118568,7 +118864,7 @@ var ts;
|
|
|
118568
118864
|
// `result[i]` is either a `ResolvedModuleFull` or a marker.
|
|
118569
118865
|
// If it is the former, we can leave it as is.
|
|
118570
118866
|
if (result[i] === predictedToResolveToAmbientModuleMarker) {
|
|
118571
|
-
result[i] =
|
|
118867
|
+
result[i] = emptyResolution;
|
|
118572
118868
|
}
|
|
118573
118869
|
}
|
|
118574
118870
|
else {
|
|
@@ -118603,6 +118899,96 @@ var ts;
|
|
|
118603
118899
|
return true;
|
|
118604
118900
|
}
|
|
118605
118901
|
}
|
|
118902
|
+
function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
|
|
118903
|
+
var _a;
|
|
118904
|
+
if (structureIsReused === 0 /* Not */) {
|
|
118905
|
+
return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, /*partialResolutionInfo*/ undefined, /*redirectedReference*/ undefined);
|
|
118906
|
+
}
|
|
118907
|
+
var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
|
|
118908
|
+
var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
|
|
118909
|
+
var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
|
|
118910
|
+
if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
118911
|
+
// `file` was created for the new program.
|
|
118912
|
+
//
|
|
118913
|
+
// We only set `file.resolvedTypeReferenceDirectiveNames` via work from the current function,
|
|
118914
|
+
// so it is defined iff we already called the current function on `file`.
|
|
118915
|
+
// That call happened no later than the creation of the `file` object,
|
|
118916
|
+
// which per above occurred during the current program creation.
|
|
118917
|
+
// Since we assume the filesystem does not change during program creation,
|
|
118918
|
+
// it is safe to reuse resolutions from the earlier call.
|
|
118919
|
+
var result_15 = [];
|
|
118920
|
+
for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
|
|
118921
|
+
var typeDirectiveName = _b[_i];
|
|
118922
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
118923
|
+
var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
|
|
118924
|
+
result_15.push(resolvedTypeReferenceDirective);
|
|
118925
|
+
}
|
|
118926
|
+
return result_15;
|
|
118927
|
+
}
|
|
118928
|
+
/** An ordered list of module names for which we cannot recover the resolution. */
|
|
118929
|
+
var unknownTypeReferenceDirectiveNames;
|
|
118930
|
+
var unknownTypeReferenceDirectiveNamesIndex;
|
|
118931
|
+
/**
|
|
118932
|
+
* The indexing of elements in this list matches that of `moduleNames`.
|
|
118933
|
+
*
|
|
118934
|
+
* Before combining results, result[i] is in one of the following states:
|
|
118935
|
+
* * undefined: needs to be recomputed,
|
|
118936
|
+
*/
|
|
118937
|
+
var result;
|
|
118938
|
+
var reusedNames;
|
|
118939
|
+
var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
|
|
118940
|
+
containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
|
|
118941
|
+
!hasInvalidatedResolution(toPath(inferredTypeFile)));
|
|
118942
|
+
var redirectedReference;
|
|
118943
|
+
for (var i = 0; i < typeDirectiveNames.length; i++) {
|
|
118944
|
+
var entry = typeDirectiveNames[i];
|
|
118945
|
+
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
|
|
118946
|
+
if (canReuseResolutions) {
|
|
118947
|
+
var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
118948
|
+
var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
|
|
118949
|
+
var oldResolution = !oldBuildInfoProgram ?
|
|
118950
|
+
(_a = (containingSourceFile ? oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedTypeReferenceDirectiveNames : oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions())) === null || _a === void 0 ? void 0 : _a.get(typeDirectiveName, mode) :
|
|
118951
|
+
oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
|
|
118952
|
+
if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
|
|
118953
|
+
if (ts.isTraceEnabled(options, host)) {
|
|
118954
|
+
var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
|
|
118955
|
+
if (!oldBuildInfoProgram) {
|
|
118956
|
+
ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
|
|
118957
|
+
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
|
|
118958
|
+
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2, typeDirectiveName, fileLocation, oldResolution.resolvedTypeReferenceDirective.resolvedFileName, oldResolution.resolvedTypeReferenceDirective.packageId && ts.packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId));
|
|
118959
|
+
}
|
|
118960
|
+
else {
|
|
118961
|
+
ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
|
|
118962
|
+
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
|
|
118963
|
+
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3, typeDirectiveName, fileLocation, ts.getDirectoryPath(fileLocation), oldResolution.resolvedTypeReferenceDirective.resolvedFileName, oldResolution.resolvedTypeReferenceDirective.packageId && ts.packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId));
|
|
118964
|
+
}
|
|
118965
|
+
}
|
|
118966
|
+
(result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
|
|
118967
|
+
(reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
|
|
118968
|
+
continue;
|
|
118969
|
+
}
|
|
118970
|
+
}
|
|
118971
|
+
// Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
|
|
118972
|
+
(unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
|
|
118973
|
+
(unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
|
|
118974
|
+
}
|
|
118975
|
+
if (!unknownTypeReferenceDirectiveNames)
|
|
118976
|
+
return result || ts.emptyArray;
|
|
118977
|
+
var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
|
|
118978
|
+
if (!result) {
|
|
118979
|
+
ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
|
|
118980
|
+
return resolutions;
|
|
118981
|
+
}
|
|
118982
|
+
var j = 0;
|
|
118983
|
+
for (var i = 0; i < result.length; i++) {
|
|
118984
|
+
if (!result[i]) {
|
|
118985
|
+
result[i] = resolutions[j];
|
|
118986
|
+
j++;
|
|
118987
|
+
}
|
|
118988
|
+
}
|
|
118989
|
+
ts.Debug.assert(j === resolutions.length);
|
|
118990
|
+
return result;
|
|
118991
|
+
}
|
|
118606
118992
|
function canReuseProjectReferences() {
|
|
118607
118993
|
return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
|
|
118608
118994
|
var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
|
|
@@ -118624,14 +119010,19 @@ var ts;
|
|
|
118624
119010
|
});
|
|
118625
119011
|
}
|
|
118626
119012
|
function tryReuseStructureFromOldProgram() {
|
|
118627
|
-
var _a, _b;
|
|
118628
|
-
if (!oldProgram) {
|
|
118629
|
-
return 0 /* Not */;
|
|
118630
|
-
}
|
|
118631
119013
|
// check properties that can affect structure of the program or module resolution strategy
|
|
118632
119014
|
// if any of these properties has changed - structure cannot be reused
|
|
118633
|
-
var oldOptions = oldProgram.getCompilerOptions();
|
|
118634
|
-
if (ts.changesAffectModuleResolution(oldOptions, options)) {
|
|
119015
|
+
var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
|
|
119016
|
+
if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
|
|
119017
|
+
return 0 /* Not */;
|
|
119018
|
+
}
|
|
119019
|
+
var result = tryReuseStructureFromOldProgramWorker();
|
|
119020
|
+
return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 /* Not */ ?
|
|
119021
|
+
1 /* SafeModuleCache */ :
|
|
119022
|
+
result;
|
|
119023
|
+
}
|
|
119024
|
+
function tryReuseStructureFromOldProgramWorker() {
|
|
119025
|
+
if (!oldProgram) {
|
|
118635
119026
|
return 0 /* Not */;
|
|
118636
119027
|
}
|
|
118637
119028
|
// there is an old program, check if we can reuse its structure
|
|
@@ -118649,7 +119040,7 @@ var ts;
|
|
|
118649
119040
|
// check if program source files has changed in the way that can affect structure of the program
|
|
118650
119041
|
var newSourceFiles = [];
|
|
118651
119042
|
var modifiedSourceFiles = [];
|
|
118652
|
-
structureIsReused =
|
|
119043
|
+
structureIsReused = 3 /* Completely */;
|
|
118653
119044
|
// If the missing file paths are now present, it can change the progam structure,
|
|
118654
119045
|
// and hence cant reuse the structure.
|
|
118655
119046
|
// This is same as how we dont reuse the structure if one of the file from old program is now missing
|
|
@@ -118665,14 +119056,13 @@ var ts;
|
|
|
118665
119056
|
var seenPackageNames = new ts.Map();
|
|
118666
119057
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
118667
119058
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
118668
|
-
var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName
|
|
119059
|
+
var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
|
|
118669
119060
|
var newSourceFile = host.getSourceFileByPath
|
|
118670
119061
|
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
|
|
118671
119062
|
: host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
|
|
118672
119063
|
if (!newSourceFile) {
|
|
118673
119064
|
return 0 /* Not */;
|
|
118674
119065
|
}
|
|
118675
|
-
newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
118676
119066
|
newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
118677
119067
|
ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
|
|
118678
119068
|
var fileChanged = void 0;
|
|
@@ -118714,41 +119104,41 @@ var ts;
|
|
|
118714
119104
|
}
|
|
118715
119105
|
if (fileChanged) {
|
|
118716
119106
|
if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
|
|
118717
|
-
structureIsReused =
|
|
119107
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118718
119108
|
}
|
|
118719
119109
|
// The `newSourceFile` object was created for the new program.
|
|
118720
119110
|
else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118721
119111
|
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
|
|
118722
|
-
structureIsReused =
|
|
119112
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118723
119113
|
}
|
|
118724
119114
|
else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118725
119115
|
// value of no-default-lib has changed
|
|
118726
119116
|
// this will affect if default library is injected into the list of files
|
|
118727
|
-
structureIsReused =
|
|
119117
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118728
119118
|
}
|
|
118729
119119
|
// check tripleslash references
|
|
118730
119120
|
else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118731
119121
|
// tripleslash references has changed
|
|
118732
|
-
structureIsReused =
|
|
119122
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118733
119123
|
}
|
|
118734
119124
|
else {
|
|
118735
119125
|
// check imports and module augmentations
|
|
118736
119126
|
collectExternalModuleReferences(newSourceFile);
|
|
118737
119127
|
if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
|
118738
119128
|
// imports has changed
|
|
118739
|
-
structureIsReused =
|
|
119129
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118740
119130
|
}
|
|
118741
119131
|
else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
|
118742
119132
|
// moduleAugmentations has changed
|
|
118743
|
-
structureIsReused =
|
|
119133
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118744
119134
|
}
|
|
118745
119135
|
else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
118746
119136
|
// dynamicImport has changed
|
|
118747
|
-
structureIsReused =
|
|
119137
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118748
119138
|
}
|
|
118749
119139
|
else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118750
119140
|
// 'types' references has changed
|
|
118751
|
-
structureIsReused =
|
|
119141
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118752
119142
|
}
|
|
118753
119143
|
}
|
|
118754
119144
|
// tentatively approve the file
|
|
@@ -118756,63 +119146,72 @@ var ts;
|
|
|
118756
119146
|
}
|
|
118757
119147
|
else if (hasInvalidatedResolution(oldSourceFile.path)) {
|
|
118758
119148
|
// 'module/types' references could have changed
|
|
118759
|
-
structureIsReused =
|
|
119149
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118760
119150
|
// add file to the modified list so that we will resolve it later
|
|
118761
119151
|
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
|
|
118762
119152
|
}
|
|
118763
119153
|
// if file has passed all checks it should be safe to reuse it
|
|
118764
119154
|
newSourceFiles.push(newSourceFile);
|
|
118765
119155
|
}
|
|
118766
|
-
if (structureIsReused !==
|
|
119156
|
+
if (structureIsReused !== 3 /* Completely */) {
|
|
118767
119157
|
return structureIsReused;
|
|
118768
119158
|
}
|
|
118769
119159
|
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
|
|
118770
|
-
for (var
|
|
118771
|
-
var oldFile = oldSourceFiles_3[
|
|
119160
|
+
for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
|
|
119161
|
+
var oldFile = oldSourceFiles_3[_a];
|
|
118772
119162
|
if (!ts.contains(modifiedFiles, oldFile)) {
|
|
118773
|
-
for (var
|
|
118774
|
-
var moduleName =
|
|
119163
|
+
for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
|
|
119164
|
+
var moduleName = _c[_b];
|
|
118775
119165
|
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
|
|
118776
119166
|
}
|
|
118777
119167
|
}
|
|
118778
119168
|
}
|
|
118779
119169
|
// try to verify results of module resolution
|
|
118780
|
-
for (var
|
|
118781
|
-
var
|
|
119170
|
+
for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
|
|
119171
|
+
var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
|
|
118782
119172
|
var moduleNames = getModuleNames(newSourceFile);
|
|
118783
119173
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
118784
119174
|
// ensure that module resolution results are still correct
|
|
118785
119175
|
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
|
|
118786
119176
|
if (resolutionsChanged) {
|
|
118787
|
-
structureIsReused =
|
|
119177
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118788
119178
|
newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
|
|
118789
119179
|
}
|
|
118790
119180
|
else {
|
|
118791
119181
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
118792
119182
|
}
|
|
118793
119183
|
var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
118794
|
-
var typeReferenceResolutions =
|
|
119184
|
+
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
|
|
118795
119185
|
// ensure that types resolutions are still correct
|
|
118796
119186
|
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
118797
119187
|
if (typeReferenceResolutionsChanged) {
|
|
118798
|
-
structureIsReused =
|
|
119188
|
+
structureIsReused = 2 /* SafeModules */;
|
|
118799
119189
|
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
|
|
118800
119190
|
}
|
|
118801
119191
|
else {
|
|
118802
119192
|
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
|
118803
119193
|
}
|
|
118804
119194
|
}
|
|
118805
|
-
if (structureIsReused !==
|
|
119195
|
+
if (structureIsReused !== 3 /* Completely */) {
|
|
118806
119196
|
return structureIsReused;
|
|
118807
119197
|
}
|
|
118808
|
-
if (ts.changesAffectingProgramStructure(
|
|
118809
|
-
return
|
|
119198
|
+
if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
|
|
119199
|
+
return 2 /* SafeModules */;
|
|
119200
|
+
}
|
|
119201
|
+
if (host.hasChangedAutomaticTypeDirectiveNames) {
|
|
119202
|
+
if (host.hasChangedAutomaticTypeDirectiveNames())
|
|
119203
|
+
return 2 /* SafeModules */;
|
|
119204
|
+
}
|
|
119205
|
+
else {
|
|
119206
|
+
automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
|
|
119207
|
+
if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
|
|
119208
|
+
return 2 /* SafeModules */;
|
|
118810
119209
|
}
|
|
118811
119210
|
missingFilePaths = oldProgram.getMissingFilePaths();
|
|
118812
119211
|
// update fileName -> file mapping
|
|
118813
119212
|
ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
|
|
118814
|
-
for (var
|
|
118815
|
-
var newSourceFile = newSourceFiles_1[
|
|
119213
|
+
for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
|
|
119214
|
+
var newSourceFile = newSourceFiles_1[_f];
|
|
118816
119215
|
filesByName.set(newSourceFile.path, newSourceFile);
|
|
118817
119216
|
}
|
|
118818
119217
|
var oldFilesByNameMap = oldProgram.getFilesByNameMap();
|
|
@@ -118834,10 +119233,12 @@ var ts;
|
|
|
118834
119233
|
fileReasons = oldProgram.getFileIncludeReasons();
|
|
118835
119234
|
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
|
|
118836
119235
|
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
|
|
119236
|
+
automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
|
|
119237
|
+
automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
|
|
118837
119238
|
sourceFileToPackageName = oldProgram.sourceFileToPackageName;
|
|
118838
119239
|
redirectTargetsMap = oldProgram.redirectTargetsMap;
|
|
118839
119240
|
usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
|
|
118840
|
-
return
|
|
119241
|
+
return 3 /* Completely */;
|
|
118841
119242
|
}
|
|
118842
119243
|
function getEmitHost(writeFileCallback) {
|
|
118843
119244
|
return {
|
|
@@ -119596,14 +119997,12 @@ var ts;
|
|
|
119596
119997
|
}
|
|
119597
119998
|
}
|
|
119598
119999
|
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
|
|
119599
|
-
var _a;
|
|
119600
120000
|
var redirect = Object.create(redirectTarget);
|
|
119601
120001
|
redirect.fileName = fileName;
|
|
119602
120002
|
redirect.path = path;
|
|
119603
120003
|
redirect.resolvedPath = resolvedPath;
|
|
119604
120004
|
redirect.originalFileName = originalFileName;
|
|
119605
120005
|
redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
|
|
119606
|
-
redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119607
120006
|
redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119608
120007
|
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
|
119609
120008
|
Object.defineProperties(redirect, {
|
|
@@ -119629,7 +120028,7 @@ var ts;
|
|
|
119629
120028
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
119630
120029
|
return result;
|
|
119631
120030
|
}
|
|
119632
|
-
function getCreateSourceFileOptions(fileName
|
|
120031
|
+
function getCreateSourceFileOptions(fileName) {
|
|
119633
120032
|
// It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
|
|
119634
120033
|
// and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
|
|
119635
120034
|
// to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
|
|
@@ -119640,7 +120039,7 @@ var ts;
|
|
|
119640
120039
|
{ languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
|
|
119641
120040
|
}
|
|
119642
120041
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
119643
|
-
var _a
|
|
120042
|
+
var _a;
|
|
119644
120043
|
var path = toPath(fileName);
|
|
119645
120044
|
if (useSourceOfProjectReferenceRedirect) {
|
|
119646
120045
|
var source = getSourceOfProjectReferenceRedirect(path);
|
|
@@ -119727,7 +120126,7 @@ var ts;
|
|
|
119727
120126
|
}
|
|
119728
120127
|
}
|
|
119729
120128
|
// We haven't looked for this file, do so now and cache result
|
|
119730
|
-
var sourceFileOptions = getCreateSourceFileOptions(fileName
|
|
120129
|
+
var sourceFileOptions = getCreateSourceFileOptions(fileName);
|
|
119731
120130
|
var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat));
|
|
119732
120131
|
if (packageId) {
|
|
119733
120132
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
@@ -119756,7 +120155,6 @@ var ts;
|
|
|
119756
120155
|
file.path = path;
|
|
119757
120156
|
file.resolvedPath = toPath(fileName);
|
|
119758
120157
|
file.originalFileName = originalFileName;
|
|
119759
|
-
file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119760
120158
|
file.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119761
120159
|
addFileIncludeReason(file, reason);
|
|
119762
120160
|
if (host.useCaseSensitiveFileNames()) {
|
|
@@ -119885,35 +120283,42 @@ var ts;
|
|
|
119885
120283
|
}
|
|
119886
120284
|
function processTypeReferenceDirectives(file) {
|
|
119887
120285
|
var typeDirectives = file.typeReferenceDirectives;
|
|
119888
|
-
if (!typeDirectives) {
|
|
120286
|
+
if (!typeDirectives.length) {
|
|
120287
|
+
file.resolvedTypeReferenceDirectiveNames = undefined;
|
|
119889
120288
|
return;
|
|
119890
120289
|
}
|
|
119891
|
-
var resolutions =
|
|
120290
|
+
var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
|
|
119892
120291
|
for (var index = 0; index < typeDirectives.length; index++) {
|
|
119893
120292
|
var ref = file.typeReferenceDirectives[index];
|
|
119894
120293
|
var resolvedTypeReferenceDirective = resolutions[index];
|
|
119895
120294
|
// store resolved type directive on the file
|
|
119896
120295
|
var fileName = ts.toFileNameLowerCase(ref.fileName);
|
|
119897
|
-
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
120296
|
+
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
|
|
119898
120297
|
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
119899
120298
|
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
119900
|
-
|
|
120299
|
+
(fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
|
|
120300
|
+
kind: 2 /* ResolutionDiagnostics */,
|
|
120301
|
+
diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
|
|
120302
|
+
});
|
|
119901
120303
|
}
|
|
119902
120304
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
119903
120305
|
}
|
|
119904
120306
|
}
|
|
119905
|
-
function processTypeReferenceDirective(typeReferenceDirective, mode,
|
|
119906
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
|
|
119907
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode,
|
|
120307
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
|
|
120308
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
|
|
120309
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
|
|
119908
120310
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
119909
120311
|
}
|
|
119910
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode,
|
|
120312
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
|
|
120313
|
+
var _a;
|
|
120314
|
+
addResolutionDiagnostics(resolution);
|
|
119911
120315
|
// If we already found this library as a primary reference - nothing to do
|
|
119912
|
-
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
|
|
120316
|
+
var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
|
|
119913
120317
|
if (previousResolution && previousResolution.primary) {
|
|
119914
120318
|
return;
|
|
119915
120319
|
}
|
|
119916
120320
|
var saveResolution = true;
|
|
120321
|
+
var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
|
|
119917
120322
|
if (resolvedTypeReferenceDirective) {
|
|
119918
120323
|
if (resolvedTypeReferenceDirective.isExternalLibraryImport)
|
|
119919
120324
|
currentNodeModulesDepth++;
|
|
@@ -119948,7 +120353,7 @@ var ts;
|
|
|
119948
120353
|
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
119949
120354
|
}
|
|
119950
120355
|
if (saveResolution) {
|
|
119951
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode,
|
|
120356
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
|
|
119952
120357
|
}
|
|
119953
120358
|
}
|
|
119954
120359
|
function pathForLibFile(libFileName) {
|
|
@@ -119981,7 +120386,7 @@ var ts;
|
|
|
119981
120386
|
var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
|
|
119982
120387
|
var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
|
|
119983
120388
|
var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
|
|
119984
|
-
(fileProcessingDiagnostics
|
|
120389
|
+
(fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
|
|
119985
120390
|
kind: 0 /* FilePreprocessingReferencedDiagnostic */,
|
|
119986
120391
|
reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
|
|
119987
120392
|
diagnostic: diagnostic,
|
|
@@ -120005,13 +120410,14 @@ var ts;
|
|
|
120005
120410
|
for (var index = 0; index < moduleNames.length; index++) {
|
|
120006
120411
|
var resolution = resolutions[index];
|
|
120007
120412
|
ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
|
|
120008
|
-
|
|
120413
|
+
addResolutionDiagnostics(resolution);
|
|
120414
|
+
if (!resolution.resolvedModule) {
|
|
120009
120415
|
continue;
|
|
120010
120416
|
}
|
|
120011
|
-
var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
|
|
120012
|
-
var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
|
|
120417
|
+
var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
|
|
120418
|
+
var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
|
|
120013
120419
|
var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
|
|
120014
|
-
var resolvedFileName = resolution.resolvedFileName;
|
|
120420
|
+
var resolvedFileName = resolution.resolvedModule.resolvedFileName;
|
|
120015
120421
|
if (isFromNodeModulesSearch) {
|
|
120016
120422
|
currentNodeModulesDepth++;
|
|
120017
120423
|
}
|
|
@@ -120024,7 +120430,7 @@ var ts;
|
|
|
120024
120430
|
// Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs')
|
|
120025
120431
|
// This may still end up being an untyped module -- the file won't be included but imports will be allowed.
|
|
120026
120432
|
var shouldAddFile = resolvedFileName
|
|
120027
|
-
&& !getResolutionDiagnostic(optionsForFile, resolution)
|
|
120433
|
+
&& !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
|
|
120028
120434
|
&& !optionsForFile.noResolve
|
|
120029
120435
|
&& index < file.imports.length
|
|
120030
120436
|
&& !elideImport
|
|
@@ -120036,7 +120442,7 @@ var ts;
|
|
|
120036
120442
|
else if (shouldAddFile) {
|
|
120037
120443
|
findSourceFile(resolvedFileName,
|
|
120038
120444
|
/*isDefaultLib*/ false,
|
|
120039
|
-
/*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
|
|
120445
|
+
/*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
|
|
120040
120446
|
}
|
|
120041
120447
|
if (isFromNodeModulesSearch) {
|
|
120042
120448
|
currentNodeModulesDepth--;
|
|
@@ -120140,6 +120546,11 @@ var ts;
|
|
|
120140
120546
|
createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
|
|
120141
120547
|
}
|
|
120142
120548
|
}
|
|
120549
|
+
if (ts.isIncrementalCompilation(options))
|
|
120550
|
+
options.cacheResolutions = true;
|
|
120551
|
+
if (options.cacheResolutions && !ts.isIncrementalCompilation(options)) {
|
|
120552
|
+
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "cacheResolutions", "incremental", "composite");
|
|
120553
|
+
}
|
|
120143
120554
|
var outputFile = ts.outFile(options);
|
|
120144
120555
|
if (options.tsBuildInfoFile) {
|
|
120145
120556
|
if (!ts.isIncrementalCompilation(options)) {
|
|
@@ -120408,7 +120819,7 @@ var ts;
|
|
|
120408
120819
|
}
|
|
120409
120820
|
}
|
|
120410
120821
|
function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
|
|
120411
|
-
(fileProcessingDiagnostics
|
|
120822
|
+
(fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
|
|
120412
120823
|
kind: 1 /* FilePreprocessingFileExplainingDiagnostic */,
|
|
120413
120824
|
file: file && file.path,
|
|
120414
120825
|
fileProcessingReason: fileProcessingReason,
|
|
@@ -120676,8 +121087,8 @@ var ts;
|
|
|
120676
121087
|
if (!symlinks) {
|
|
120677
121088
|
symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
|
|
120678
121089
|
}
|
|
120679
|
-
if (files &&
|
|
120680
|
-
symlinks.setSymlinksFromResolutions(files,
|
|
121090
|
+
if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
|
|
121091
|
+
symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
|
|
120681
121092
|
}
|
|
120682
121093
|
return symlinks;
|
|
120683
121094
|
}
|
|
@@ -121090,7 +121501,8 @@ var ts;
|
|
|
121090
121501
|
}
|
|
121091
121502
|
// Handle type reference directives
|
|
121092
121503
|
if (sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
121093
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (
|
|
121504
|
+
sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
|
|
121505
|
+
var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
|
|
121094
121506
|
if (!resolvedTypeReferenceDirective) {
|
|
121095
121507
|
return;
|
|
121096
121508
|
}
|
|
@@ -121149,12 +121561,13 @@ var ts;
|
|
|
121149
121561
|
/**
|
|
121150
121562
|
* Creates the state of file references and signature for the new program from oldState if it is safe
|
|
121151
121563
|
*/
|
|
121152
|
-
function create(newProgram,
|
|
121564
|
+
function create(newProgram, oldState, disableUseFileVersionAsSignature) {
|
|
121153
121565
|
var _a, _b, _c;
|
|
121154
121566
|
var fileInfos = new ts.Map();
|
|
121155
121567
|
var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
|
|
121156
121568
|
var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
|
|
121157
121569
|
var useOldState = canReuseOldState(referencedMap, oldState);
|
|
121570
|
+
var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
|
|
121158
121571
|
// Ensure source files have parent pointers set
|
|
121159
121572
|
newProgram.getTypeChecker();
|
|
121160
121573
|
// Create the reference map, and set the file infos
|
|
@@ -121207,23 +121620,23 @@ var ts;
|
|
|
121207
121620
|
/**
|
|
121208
121621
|
* Gets the files affected by the path from the program
|
|
121209
121622
|
*/
|
|
121210
|
-
function getFilesAffectedBy(state, programOfThisState, path, cancellationToken,
|
|
121623
|
+
function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
|
|
121211
121624
|
var _a, _b;
|
|
121212
|
-
var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken,
|
|
121625
|
+
var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
|
|
121213
121626
|
(_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
|
|
121214
121627
|
(_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
|
|
121215
121628
|
return result;
|
|
121216
121629
|
}
|
|
121217
121630
|
BuilderState.getFilesAffectedBy = getFilesAffectedBy;
|
|
121218
|
-
function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken,
|
|
121631
|
+
function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
|
|
121219
121632
|
var sourceFile = programOfThisState.getSourceFileByPath(path);
|
|
121220
121633
|
if (!sourceFile) {
|
|
121221
121634
|
return ts.emptyArray;
|
|
121222
121635
|
}
|
|
121223
|
-
if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken,
|
|
121636
|
+
if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
|
|
121224
121637
|
return [sourceFile];
|
|
121225
121638
|
}
|
|
121226
|
-
return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken,
|
|
121639
|
+
return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
|
|
121227
121640
|
}
|
|
121228
121641
|
BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
|
|
121229
121642
|
function updateSignatureOfFile(state, signature, path) {
|
|
@@ -121234,7 +121647,7 @@ var ts;
|
|
|
121234
121647
|
/**
|
|
121235
121648
|
* Returns if the shape of the signature has changed since last emit
|
|
121236
121649
|
*/
|
|
121237
|
-
function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken,
|
|
121650
|
+
function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
|
|
121238
121651
|
var _a;
|
|
121239
121652
|
if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
|
|
121240
121653
|
// If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
|
|
@@ -121246,7 +121659,7 @@ var ts;
|
|
|
121246
121659
|
if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
|
|
121247
121660
|
programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
|
|
121248
121661
|
ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
|
|
121249
|
-
latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text,
|
|
121662
|
+
latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
|
|
121250
121663
|
if (latestSignature !== prevSignature) {
|
|
121251
121664
|
updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
|
|
121252
121665
|
}
|
|
@@ -121425,7 +121838,7 @@ var ts;
|
|
|
121425
121838
|
/**
|
|
121426
121839
|
* When program emits modular code, gets the files affected by the sourceFile whose shape has changed
|
|
121427
121840
|
*/
|
|
121428
|
-
function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken,
|
|
121841
|
+
function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
|
|
121429
121842
|
if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
|
|
121430
121843
|
return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
|
|
121431
121844
|
}
|
|
@@ -121445,7 +121858,7 @@ var ts;
|
|
|
121445
121858
|
if (!seenFileNamesMap.has(currentPath)) {
|
|
121446
121859
|
var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
|
|
121447
121860
|
seenFileNamesMap.set(currentPath, currentSourceFile);
|
|
121448
|
-
if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken,
|
|
121861
|
+
if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
|
|
121449
121862
|
queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
|
121450
121863
|
}
|
|
121451
121864
|
}
|
|
@@ -121470,9 +121883,9 @@ var ts;
|
|
|
121470
121883
|
/**
|
|
121471
121884
|
* Create the state so that we can iterate on changedFiles/affected files
|
|
121472
121885
|
*/
|
|
121473
|
-
function createBuilderProgramState(newProgram,
|
|
121886
|
+
function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
|
|
121474
121887
|
var _a, _b;
|
|
121475
|
-
var state = ts.BuilderState.create(newProgram,
|
|
121888
|
+
var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
|
|
121476
121889
|
state.program = newProgram;
|
|
121477
121890
|
var compilerOptions = newProgram.getCompilerOptions();
|
|
121478
121891
|
state.compilerOptions = compilerOptions;
|
|
@@ -121536,7 +121949,7 @@ var ts;
|
|
|
121536
121949
|
// Unchanged file copy diagnostics
|
|
121537
121950
|
var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
|
|
121538
121951
|
if (diagnostics) {
|
|
121539
|
-
state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram
|
|
121952
|
+
state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
|
|
121540
121953
|
if (!state.semanticDiagnosticsFromOldState) {
|
|
121541
121954
|
state.semanticDiagnosticsFromOldState = new ts.Set();
|
|
121542
121955
|
}
|
|
@@ -121561,13 +121974,16 @@ var ts;
|
|
|
121561
121974
|
state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
|
|
121562
121975
|
}
|
|
121563
121976
|
// Since old states change files set is copied, any additional change means we would need to emit build info
|
|
121564
|
-
state.buildInfoEmitPending = !useOldState ||
|
|
121977
|
+
state.buildInfoEmitPending = !useOldState ||
|
|
121978
|
+
state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
|
|
121979
|
+
state.fileInfos.size !== oldState.fileInfos.size;
|
|
121565
121980
|
return state;
|
|
121566
121981
|
}
|
|
121567
|
-
function convertToDiagnostics(diagnostics, newProgram
|
|
121982
|
+
function convertToDiagnostics(diagnostics, newProgram) {
|
|
121568
121983
|
if (!diagnostics.length)
|
|
121569
121984
|
return ts.emptyArray;
|
|
121570
|
-
var buildInfoDirectory
|
|
121985
|
+
var buildInfoDirectory;
|
|
121986
|
+
var getCanonicalFileName;
|
|
121571
121987
|
return diagnostics.map(function (diagnostic) {
|
|
121572
121988
|
var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
|
|
121573
121989
|
result.reportsUnnecessary = diagnostic.reportsUnnecessary;
|
|
@@ -121583,7 +121999,8 @@ var ts;
|
|
|
121583
121999
|
return result;
|
|
121584
122000
|
});
|
|
121585
122001
|
function toPath(path) {
|
|
121586
|
-
|
|
122002
|
+
buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
|
|
122003
|
+
return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
|
|
121587
122004
|
}
|
|
121588
122005
|
}
|
|
121589
122006
|
function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
|
|
@@ -121595,6 +122012,9 @@ var ts;
|
|
|
121595
122012
|
*/
|
|
121596
122013
|
function releaseCache(state) {
|
|
121597
122014
|
ts.BuilderState.releaseCache(state);
|
|
122015
|
+
// Store the resolutions if possible
|
|
122016
|
+
if (!state.resuableCacheResolutions)
|
|
122017
|
+
getCacheResolutions(state);
|
|
121598
122018
|
state.program = undefined;
|
|
121599
122019
|
}
|
|
121600
122020
|
function backupBuilderProgramEmitState(state) {
|
|
@@ -121639,7 +122059,7 @@ var ts;
|
|
|
121639
122059
|
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
|
|
121640
122060
|
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
|
|
121641
122061
|
*/
|
|
121642
|
-
function getNextAffectedFile(state, cancellationToken,
|
|
122062
|
+
function getNextAffectedFile(state, cancellationToken, host) {
|
|
121643
122063
|
var _a, _b;
|
|
121644
122064
|
while (true) {
|
|
121645
122065
|
var affectedFiles = state.affectedFiles;
|
|
@@ -121651,7 +122071,7 @@ var ts;
|
|
|
121651
122071
|
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
|
|
121652
122072
|
// Set the next affected file as seen and remove the cached semantic diagnostics
|
|
121653
122073
|
state.affectedFilesIndex = affectedFilesIndex;
|
|
121654
|
-
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken,
|
|
122074
|
+
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
|
|
121655
122075
|
return affectedFile;
|
|
121656
122076
|
}
|
|
121657
122077
|
affectedFilesIndex++;
|
|
@@ -121679,7 +122099,7 @@ var ts;
|
|
|
121679
122099
|
return program;
|
|
121680
122100
|
}
|
|
121681
122101
|
// Get next batch of affected files
|
|
121682
|
-
state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken,
|
|
122102
|
+
state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
|
|
121683
122103
|
state.currentChangedFilePath = nextKey.value;
|
|
121684
122104
|
state.affectedFilesIndex = 0;
|
|
121685
122105
|
if (!state.seenAffectedFiles)
|
|
@@ -121730,7 +122150,7 @@ var ts;
|
|
|
121730
122150
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
121731
122151
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
121732
122152
|
*/
|
|
121733
|
-
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken,
|
|
122153
|
+
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
|
|
121734
122154
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
121735
122155
|
// If affected files is everything except default library, then nothing more to do
|
|
121736
122156
|
if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
|
|
@@ -121738,18 +122158,18 @@ var ts;
|
|
|
121738
122158
|
// When a change affects the global scope, all files are considered to be affected without updating their signature
|
|
121739
122159
|
// That means when affected file is handled, its signature can be out of date
|
|
121740
122160
|
// To avoid this, ensure that we update the signature for any affected file in this scenario.
|
|
121741
|
-
ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken,
|
|
122161
|
+
ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
|
|
121742
122162
|
return;
|
|
121743
122163
|
}
|
|
121744
122164
|
if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
|
|
121745
122165
|
return;
|
|
121746
|
-
handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken,
|
|
122166
|
+
handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
|
|
121747
122167
|
}
|
|
121748
122168
|
/**
|
|
121749
122169
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
121750
122170
|
* Also we need to make sure signature is updated for these files
|
|
121751
122171
|
*/
|
|
121752
|
-
function handleDtsMayChangeOf(state, path, cancellationToken,
|
|
122172
|
+
function handleDtsMayChangeOf(state, path, cancellationToken, host) {
|
|
121753
122173
|
removeSemanticDiagnosticsOf(state, path);
|
|
121754
122174
|
if (!state.changedFilesSet.has(path)) {
|
|
121755
122175
|
var program = ts.Debug.checkDefined(state.program);
|
|
@@ -121760,7 +122180,7 @@ var ts;
|
|
|
121760
122180
|
// This ensures that we dont later during incremental builds considering wrong signature.
|
|
121761
122181
|
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
|
|
121762
122182
|
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
|
|
121763
|
-
ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken,
|
|
122183
|
+
ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
|
|
121764
122184
|
// If not dts emit, nothing more to do
|
|
121765
122185
|
if (ts.getEmitDeclarations(state.compilerOptions)) {
|
|
121766
122186
|
addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
|
|
@@ -121785,20 +122205,20 @@ var ts;
|
|
|
121785
122205
|
var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
|
|
121786
122206
|
return newSignature !== oldSignature;
|
|
121787
122207
|
}
|
|
121788
|
-
function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken,
|
|
122208
|
+
function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
|
|
121789
122209
|
var _a;
|
|
121790
122210
|
if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
|
|
121791
122211
|
return false;
|
|
121792
122212
|
// Every file needs to be handled
|
|
121793
122213
|
ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
|
|
121794
|
-
.forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken,
|
|
122214
|
+
.forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
|
|
121795
122215
|
removeDiagnosticsOfLibraryFiles(state);
|
|
121796
122216
|
return true;
|
|
121797
122217
|
}
|
|
121798
122218
|
/**
|
|
121799
122219
|
* Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
|
|
121800
122220
|
*/
|
|
121801
|
-
function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken,
|
|
122221
|
+
function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
|
|
121802
122222
|
var _a;
|
|
121803
122223
|
// If there was change in signature (dts output) for the changed file,
|
|
121804
122224
|
// then only we need to handle pending file emit
|
|
@@ -121816,9 +122236,9 @@ var ts;
|
|
|
121816
122236
|
var currentPath = queue.pop();
|
|
121817
122237
|
if (!seenFileNamesMap.has(currentPath)) {
|
|
121818
122238
|
seenFileNamesMap.set(currentPath, true);
|
|
121819
|
-
if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken,
|
|
122239
|
+
if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
|
|
121820
122240
|
return;
|
|
121821
|
-
handleDtsMayChangeOf(state, currentPath, cancellationToken,
|
|
122241
|
+
handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
|
|
121822
122242
|
if (isChangedSignature(state, currentPath)) {
|
|
121823
122243
|
var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
|
|
121824
122244
|
queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
|
@@ -121830,11 +122250,11 @@ var ts;
|
|
|
121830
122250
|
// Go through exported modules from cache first
|
|
121831
122251
|
// If exported modules has path, all files referencing file exported from are affected
|
|
121832
122252
|
(_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
|
|
121833
|
-
if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken,
|
|
122253
|
+
if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
|
|
121834
122254
|
return true;
|
|
121835
122255
|
var references = state.referencedMap.getKeys(exportedFromPath);
|
|
121836
122256
|
return references && ts.forEachKey(references, function (filePath) {
|
|
121837
|
-
return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken,
|
|
122257
|
+
return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
|
|
121838
122258
|
});
|
|
121839
122259
|
});
|
|
121840
122260
|
}
|
|
@@ -121842,22 +122262,22 @@ var ts;
|
|
|
121842
122262
|
* handle dts and semantic diagnostics on file and iterate on anything that exports this file
|
|
121843
122263
|
* return true when all work is done and we can exit handling dts emit and semantic diagnostics
|
|
121844
122264
|
*/
|
|
121845
|
-
function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken,
|
|
122265
|
+
function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
|
|
121846
122266
|
var _a, _b;
|
|
121847
122267
|
if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
|
|
121848
122268
|
return undefined;
|
|
121849
|
-
if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken,
|
|
122269
|
+
if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
|
|
121850
122270
|
return true;
|
|
121851
|
-
handleDtsMayChangeOf(state, filePath, cancellationToken,
|
|
122271
|
+
handleDtsMayChangeOf(state, filePath, cancellationToken, host);
|
|
121852
122272
|
// If exported modules has path, all files referencing file exported from are affected
|
|
121853
122273
|
(_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
|
|
121854
|
-
return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken,
|
|
122274
|
+
return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
|
|
121855
122275
|
});
|
|
121856
122276
|
// Remove diagnostics of files that import this file (without going to exports of referencing files)
|
|
121857
122277
|
(_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
|
|
121858
122278
|
return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
|
|
121859
122279
|
handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
|
|
121860
|
-
state, referencingFilePath, cancellationToken,
|
|
122280
|
+
state, referencingFilePath, cancellationToken, host);
|
|
121861
122281
|
});
|
|
121862
122282
|
return undefined;
|
|
121863
122283
|
}
|
|
@@ -121936,35 +122356,46 @@ var ts;
|
|
|
121936
122356
|
/**
|
|
121937
122357
|
* Gets the program information to be emitted in buildInfo so that we can use it to create new program
|
|
121938
122358
|
*/
|
|
121939
|
-
function getProgramBuildInfo(state,
|
|
122359
|
+
function getProgramBuildInfo(state, host) {
|
|
121940
122360
|
var outFilePath = ts.outFile(state.compilerOptions);
|
|
121941
|
-
if (outFilePath && !state.compilerOptions.composite)
|
|
122361
|
+
if (outFilePath && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
|
|
121942
122362
|
return;
|
|
121943
122363
|
var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
|
|
121944
|
-
var
|
|
122364
|
+
var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
|
|
122365
|
+
var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
|
|
122366
|
+
var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
|
|
121945
122367
|
// Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path
|
|
121946
122368
|
var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
|
|
122369
|
+
var fileNames = [];
|
|
122370
|
+
var fileNameToFileId = new ts.Map();
|
|
122371
|
+
var resolutions;
|
|
122372
|
+
var names;
|
|
122373
|
+
var resolutionNameToResolutionNameId;
|
|
122374
|
+
var resolutionEntries;
|
|
122375
|
+
var resolutionEntryToResolutionEntryId;
|
|
122376
|
+
var affectedFilesHash;
|
|
121947
122377
|
if (outFilePath) {
|
|
121948
|
-
var
|
|
121949
|
-
|
|
121950
|
-
|
|
121951
|
-
|
|
121952
|
-
|
|
121953
|
-
|
|
121954
|
-
|
|
121955
|
-
|
|
121956
|
-
|
|
121957
|
-
|
|
121958
|
-
|
|
122378
|
+
var fileInfos_1;
|
|
122379
|
+
if (state.compilerOptions.composite) {
|
|
122380
|
+
state.program.getRootFileNames().forEach(function (f) {
|
|
122381
|
+
var sourceFile = state.program.getSourceFile(f);
|
|
122382
|
+
if (!sourceFile)
|
|
122383
|
+
return;
|
|
122384
|
+
var fileId = toFileId(sourceFile.resolvedPath);
|
|
122385
|
+
(fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
|
|
122386
|
+
});
|
|
122387
|
+
}
|
|
122388
|
+
var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
|
|
122389
|
+
var result_16 = {
|
|
122390
|
+
fileNames: fileNames,
|
|
121959
122391
|
fileInfos: fileInfos_1,
|
|
121960
|
-
options:
|
|
122392
|
+
options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
|
|
121961
122393
|
outSignature: state.outSignature,
|
|
121962
122394
|
latestChangedDtsFile: latestChangedDtsFile,
|
|
122395
|
+
cacheResolutions: cacheResolutions_1,
|
|
121963
122396
|
};
|
|
121964
|
-
return
|
|
122397
|
+
return result_16;
|
|
121965
122398
|
}
|
|
121966
|
-
var fileNames = [];
|
|
121967
|
-
var fileNameToFileId = new ts.Map();
|
|
121968
122399
|
var fileIdsList;
|
|
121969
122400
|
var fileNamesToFileIdListId;
|
|
121970
122401
|
var emitSignatures;
|
|
@@ -122028,7 +122459,7 @@ var ts;
|
|
|
122028
122459
|
(semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
|
|
122029
122460
|
[
|
|
122030
122461
|
toFileId(key),
|
|
122031
|
-
|
|
122462
|
+
value.map(toReusableDiagnostic)
|
|
122032
122463
|
] :
|
|
122033
122464
|
toFileId(key));
|
|
122034
122465
|
}
|
|
@@ -122050,10 +122481,11 @@ var ts;
|
|
|
122050
122481
|
(changeFileSet || (changeFileSet = [])).push(toFileId(path));
|
|
122051
122482
|
}
|
|
122052
122483
|
}
|
|
122484
|
+
var cacheResolutions = toProgramBuildInfoCacheResolutions();
|
|
122053
122485
|
var result = {
|
|
122054
122486
|
fileNames: fileNames,
|
|
122055
122487
|
fileInfos: fileInfos,
|
|
122056
|
-
options:
|
|
122488
|
+
options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
|
|
122057
122489
|
fileIdsList: fileIdsList,
|
|
122058
122490
|
referencedMap: referencedMap,
|
|
122059
122491
|
exportedModulesMap: exportedModulesMap,
|
|
@@ -122062,6 +122494,7 @@ var ts;
|
|
|
122062
122494
|
changeFileSet: changeFileSet,
|
|
122063
122495
|
emitSignatures: emitSignatures,
|
|
122064
122496
|
latestChangedDtsFile: latestChangedDtsFile,
|
|
122497
|
+
cacheResolutions: cacheResolutions,
|
|
122065
122498
|
};
|
|
122066
122499
|
return result;
|
|
122067
122500
|
function relativeToBuildInfoEnsuringAbsolutePath(path) {
|
|
@@ -122070,7 +122503,7 @@ var ts;
|
|
|
122070
122503
|
function relativeToBuildInfo(path) {
|
|
122071
122504
|
return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
|
|
122072
122505
|
}
|
|
122073
|
-
function
|
|
122506
|
+
function toFileAndAbsoluteFileId(path) {
|
|
122074
122507
|
var fileId = fileNameToFileId.get(path);
|
|
122075
122508
|
if (fileId === undefined) {
|
|
122076
122509
|
fileNames.push(relativeToBuildInfo(path));
|
|
@@ -122078,6 +122511,12 @@ var ts;
|
|
|
122078
122511
|
}
|
|
122079
122512
|
return fileId;
|
|
122080
122513
|
}
|
|
122514
|
+
function toFileId(path) {
|
|
122515
|
+
return toFileAndAbsoluteFileId(path);
|
|
122516
|
+
}
|
|
122517
|
+
function toAbsoluteFileId(path) {
|
|
122518
|
+
return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
|
|
122519
|
+
}
|
|
122081
122520
|
function toFileIdListId(set) {
|
|
122082
122521
|
var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
|
|
122083
122522
|
var key = fileIds.join();
|
|
@@ -122090,54 +122529,238 @@ var ts;
|
|
|
122090
122529
|
}
|
|
122091
122530
|
/**
|
|
122092
122531
|
* @param optionKey key of CommandLineOption to use to determine if the option should be serialized in tsbuildinfo
|
|
122532
|
+
* @param affectsModuleResolution serialize options affecting module resolution
|
|
122093
122533
|
*/
|
|
122094
|
-
function
|
|
122534
|
+
function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
|
|
122095
122535
|
var result;
|
|
122096
122536
|
var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
|
|
122097
122537
|
for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
|
|
122098
122538
|
var name = _a[_i];
|
|
122099
122539
|
var optionInfo = optionsNameMap.get(name.toLowerCase());
|
|
122100
|
-
if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
|
|
122101
|
-
(result
|
|
122540
|
+
if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
|
|
122541
|
+
(result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
|
|
122542
|
+
}
|
|
122543
|
+
else if (affectsModuleResolution && name === "pathsBasePath") {
|
|
122544
|
+
(result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
|
|
122545
|
+
continue;
|
|
122102
122546
|
}
|
|
122103
122547
|
}
|
|
122104
122548
|
return result;
|
|
122105
122549
|
}
|
|
122106
|
-
|
|
122107
|
-
|
|
122108
|
-
|
|
122109
|
-
|
|
122110
|
-
|
|
122111
|
-
|
|
122112
|
-
|
|
122550
|
+
function toReusableCompilerOptionValue(option, value) {
|
|
122551
|
+
if (option) {
|
|
122552
|
+
if (option.type === "list") {
|
|
122553
|
+
var values = value;
|
|
122554
|
+
if (option.element.isFilePath && values.length) {
|
|
122555
|
+
return values.map(relativeToBuildInfoEnsuringAbsolutePath);
|
|
122556
|
+
}
|
|
122557
|
+
}
|
|
122558
|
+
else if (option.isFilePath) {
|
|
122559
|
+
return relativeToBuildInfoEnsuringAbsolutePath(value);
|
|
122113
122560
|
}
|
|
122114
122561
|
}
|
|
122115
|
-
|
|
122116
|
-
return relativeToBuildInfo(value);
|
|
122117
|
-
}
|
|
122562
|
+
return value;
|
|
122118
122563
|
}
|
|
122119
|
-
|
|
122120
|
-
|
|
122121
|
-
|
|
122122
|
-
|
|
122123
|
-
|
|
122124
|
-
var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
|
|
122564
|
+
function toReadonlyArrayOrUndefined(array, map) {
|
|
122565
|
+
return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
|
|
122566
|
+
}
|
|
122567
|
+
function toReusableDiagnostic(diagnostic) {
|
|
122568
|
+
var result = toReusableDiagnosticRelatedInformation(diagnostic);
|
|
122125
122569
|
result.reportsUnnecessary = diagnostic.reportsUnnecessary;
|
|
122126
122570
|
result.reportDeprecated = diagnostic.reportsDeprecated;
|
|
122127
122571
|
result.source = diagnostic.source;
|
|
122128
122572
|
result.skippedOn = diagnostic.skippedOn;
|
|
122129
122573
|
var relatedInformation = diagnostic.relatedInformation;
|
|
122130
|
-
result.relatedInformation = relatedInformation ?
|
|
122131
|
-
relatedInformation.length ?
|
|
122132
|
-
relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
|
|
122133
|
-
[] :
|
|
122134
|
-
undefined;
|
|
122574
|
+
result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
|
|
122135
122575
|
return result;
|
|
122576
|
+
}
|
|
122577
|
+
function toReusableDiagnosticRelatedInformation(diagnostic) {
|
|
122578
|
+
var file = diagnostic.file;
|
|
122579
|
+
return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
|
|
122580
|
+
}
|
|
122581
|
+
function toProgramBuildInfoCacheResolutions() {
|
|
122582
|
+
var cacheResolutions = getCacheResolutions(state);
|
|
122583
|
+
var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
|
|
122584
|
+
var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
|
|
122585
|
+
var packageJsons = toProgramBuildInfoPackageJsons(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.perDirPackageJsonMap);
|
|
122586
|
+
if (!resolutions)
|
|
122587
|
+
return;
|
|
122588
|
+
ts.Debug.assertIsDefined(names);
|
|
122589
|
+
ts.Debug.assertIsDefined(resolutionEntries);
|
|
122590
|
+
state.resuableCacheResolutions = {
|
|
122591
|
+
cache: {
|
|
122592
|
+
resolutions: resolutions.map(toProgramBuildInfoResolution),
|
|
122593
|
+
names: names,
|
|
122594
|
+
hash: toProgramBuildInfoHashes(),
|
|
122595
|
+
resolutionEntries: resolutionEntries,
|
|
122596
|
+
modules: modules,
|
|
122597
|
+
typeRefs: typeRefs,
|
|
122598
|
+
packageJsons: packageJsons,
|
|
122599
|
+
},
|
|
122600
|
+
getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
|
|
122601
|
+
};
|
|
122602
|
+
return state.resuableCacheResolutions.cache;
|
|
122603
|
+
}
|
|
122604
|
+
function toProgramBuildInfoPackageJsons(cache) {
|
|
122605
|
+
var result;
|
|
122606
|
+
cache === null || cache === void 0 ? void 0 : cache.forEach(function (packageJson, dirPath) {
|
|
122607
|
+
var packageJsonDirPath = ts.getDirectoryPath(ts.toPath(packageJson, currentDirectory, getCanonicalFileName));
|
|
122608
|
+
// Dont need to store package json found in same directory
|
|
122609
|
+
if (packageJsonDirPath !== dirPath) {
|
|
122610
|
+
(result !== null && result !== void 0 ? result : (result = [])).push([
|
|
122611
|
+
toFileId(dirPath),
|
|
122612
|
+
toAbsoluteFileId(packageJson),
|
|
122613
|
+
]);
|
|
122614
|
+
}
|
|
122615
|
+
});
|
|
122616
|
+
return result;
|
|
122617
|
+
}
|
|
122618
|
+
function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
|
|
122619
|
+
if (!cache)
|
|
122620
|
+
return undefined;
|
|
122621
|
+
var ownMap = cache.getOwnMap();
|
|
122622
|
+
var own = toProgramBuildInfoResolutionCache(ownMap);
|
|
122623
|
+
var redirects;
|
|
122624
|
+
cache.redirectsKeyToCache.forEach(function (_a) {
|
|
122625
|
+
var map = _a.map, options = _a.options;
|
|
122626
|
+
if (map === ownMap)
|
|
122627
|
+
return;
|
|
122628
|
+
var redirectCache = toProgramBuildInfoResolutionCache(map);
|
|
122629
|
+
if (redirectCache) {
|
|
122630
|
+
(redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
|
|
122631
|
+
options: toProgramBuildInfoCompilerOptions(options, /*optionKey*/ undefined, /*affectsModuleResolution*/ true),
|
|
122632
|
+
cache: redirectCache
|
|
122633
|
+
});
|
|
122634
|
+
}
|
|
122635
|
+
});
|
|
122636
|
+
return !redirects ? own : { own: own, redirects: redirects };
|
|
122637
|
+
}
|
|
122638
|
+
function toProgramBuildInfoResolutionCache(cache) {
|
|
122639
|
+
var result;
|
|
122640
|
+
cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
|
|
122641
|
+
(result !== null && result !== void 0 ? result : (result = [])).push([
|
|
122642
|
+
toFileId(dirPath),
|
|
122643
|
+
ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
|
|
122644
|
+
]) :
|
|
122645
|
+
undefined; });
|
|
122646
|
+
return result;
|
|
122647
|
+
}
|
|
122648
|
+
function toProgramBuildInfoResolutionEntryId(_a) {
|
|
122649
|
+
var name = _a[0], mode = _a[1], resolution = _a[2];
|
|
122650
|
+
var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
|
|
122651
|
+
var resolutionId = toProgramBuildInfoResolutionId(resolution);
|
|
122652
|
+
var key = resolutionNameId + "," + mode + "," + resolutionId;
|
|
122653
|
+
var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
|
|
122654
|
+
if (resolutionEntryId === undefined) {
|
|
122655
|
+
(resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
|
|
122656
|
+
(resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
|
|
122657
|
+
}
|
|
122658
|
+
return resolutionEntryId;
|
|
122659
|
+
}
|
|
122660
|
+
function toProgramBuildInfoResolutionNameId(name) {
|
|
122661
|
+
var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
|
|
122662
|
+
if (resolutionNameId === undefined) {
|
|
122663
|
+
(names !== null && names !== void 0 ? names : (names = [])).push(name);
|
|
122664
|
+
(resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
|
|
122665
|
+
}
|
|
122666
|
+
return resolutionNameId;
|
|
122667
|
+
}
|
|
122668
|
+
function toProgramBuildInfoResolutionId(resolution) {
|
|
122669
|
+
if (resolution.serializationIndex === undefined) {
|
|
122670
|
+
(resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
|
|
122671
|
+
resolution.serializationIndex = resolutions.length;
|
|
122672
|
+
}
|
|
122673
|
+
return resolution.serializationIndex;
|
|
122674
|
+
}
|
|
122675
|
+
function toProgramBuildInfoResolution(resolution) {
|
|
122676
|
+
resolution.serializationIndex = undefined;
|
|
122677
|
+
return {
|
|
122678
|
+
resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
|
|
122679
|
+
resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
|
|
122680
|
+
affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
|
|
122681
|
+
resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
|
|
122682
|
+
};
|
|
122683
|
+
}
|
|
122684
|
+
function toProgramBuildInfoHashes() {
|
|
122685
|
+
if (!affectedFilesHash)
|
|
122686
|
+
return undefined;
|
|
122687
|
+
var hashes = [];
|
|
122688
|
+
for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
|
|
122689
|
+
var key = _a[_i];
|
|
122690
|
+
var value = affectedFilesHash.get(key);
|
|
122691
|
+
hashes.push(value ? [key, value] : key);
|
|
122692
|
+
}
|
|
122693
|
+
return hashes;
|
|
122694
|
+
}
|
|
122695
|
+
function toAffectedFileId(file) {
|
|
122696
|
+
var _a;
|
|
122697
|
+
var fileId = toAbsoluteFileId(file);
|
|
122698
|
+
if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
|
|
122699
|
+
// Store the file hash
|
|
122700
|
+
var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
|
|
122701
|
+
var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
|
|
122702
|
+
(affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
|
|
122703
|
+
}
|
|
122704
|
+
return fileId;
|
|
122705
|
+
}
|
|
122706
|
+
function toProgramBuildInfoResolved(resolved) {
|
|
122707
|
+
return resolved ? __assign(__assign({}, resolved), { resolvedFileName: toAbsoluteFileId(resolved.resolvedFileName), isExternalLibraryImport: resolved.isExternalLibraryImport ? true : undefined, originalPath: resolved.originalPath ? toAbsoluteFileId(resolved.originalPath) : undefined, primary: resolved.primary || undefined, extension: undefined }) : undefined;
|
|
122708
|
+
}
|
|
122709
|
+
function toProgramBuildInfoResolutionDiagnostic(d) {
|
|
122710
|
+
return {
|
|
122711
|
+
isImports: d.isImports || undefined,
|
|
122712
|
+
entry: d.entry || undefined,
|
|
122713
|
+
packagePath: toAbsoluteFileId(d.packagePath),
|
|
122714
|
+
};
|
|
122715
|
+
}
|
|
122716
|
+
}
|
|
122717
|
+
function getCacheResolutions(state) {
|
|
122718
|
+
var _a;
|
|
122719
|
+
if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
|
|
122720
|
+
return state.cacheResolutions;
|
|
122721
|
+
var modules;
|
|
122722
|
+
var typeRefs;
|
|
122723
|
+
var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
|
|
122724
|
+
var dirToPackageJsonScope = new ts.Map();
|
|
122725
|
+
var perDirPackageJsonMap;
|
|
122726
|
+
var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
|
|
122727
|
+
state.program.getSourceFiles().forEach(function (f) {
|
|
122728
|
+
var _a;
|
|
122729
|
+
modules = toPerDirectoryCache(state, getCanonicalFileName, modules, ts.getResolvedModuleOfResolution, f, f.resolvedModules, moduleNameToDirectoryMap);
|
|
122730
|
+
typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, f, f.resolvedTypeReferenceDirectiveNames);
|
|
122731
|
+
if ((_a = f.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
|
|
122732
|
+
var dirPath = ts.getDirectoryPath(f.resolvedPath);
|
|
122733
|
+
if (!(dirToPackageJsonScope === null || dirToPackageJsonScope === void 0 ? void 0 : dirToPackageJsonScope.has(dirPath))) {
|
|
122734
|
+
(perDirPackageJsonMap !== null && perDirPackageJsonMap !== void 0 ? perDirPackageJsonMap : (perDirPackageJsonMap = new ts.Map())).set(dirPath, ts.getPackageJsconLocationFromScope(f.packageJsonScope));
|
|
122735
|
+
ts.moduleNameToDirectorySet(dirToPackageJsonScope, dirPath, f.packageJsonScope, ts.getPackageJsconLocationFromScope, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath) { return perDirPackageJsonMap === null || perDirPackageJsonMap === void 0 ? void 0 : perDirPackageJsonMap.delete(ancestorPath); });
|
|
122736
|
+
}
|
|
122737
|
+
}
|
|
122136
122738
|
});
|
|
122739
|
+
var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
|
|
122740
|
+
if (automaticTypeDirectiveNames.length) {
|
|
122741
|
+
var currentDirectory = state.program.getCurrentDirectory();
|
|
122742
|
+
var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
|
|
122743
|
+
typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
|
|
122744
|
+
}
|
|
122745
|
+
return state.cacheResolutions = {
|
|
122746
|
+
modules: modules,
|
|
122747
|
+
typeRefs: typeRefs,
|
|
122748
|
+
moduleNameToDirectoryMap: moduleNameToDirectoryMap,
|
|
122749
|
+
dirToPackageJsonScope: dirToPackageJsonScope,
|
|
122750
|
+
perDirPackageJsonMap: perDirPackageJsonMap,
|
|
122751
|
+
packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
|
|
122752
|
+
};
|
|
122137
122753
|
}
|
|
122138
|
-
function
|
|
122139
|
-
|
|
122140
|
-
|
|
122754
|
+
function toPerDirectoryCache(state, getCanonicalFileName, perDirCache, getResolutionWithResolvedFileName, sourceFileOrPath, fileCacheFromProgram, moduleNameToDirectoryMap) {
|
|
122755
|
+
return ts.toPerDirectoryResolution(state.program, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, ts.noop, function (r, name, mode, _key, redirectedReference, dirPath) {
|
|
122756
|
+
var _a, _b, _c;
|
|
122757
|
+
// If this is not resolved, dont put in per dir Cache
|
|
122758
|
+
return !((_a = getResolutionWithResolvedFileName(r)) === null || _a === void 0 ? void 0 : _a.resolvedFileName) ||
|
|
122759
|
+
// If there was already external module resolution that is same, set for child directory, dont set resolution for this directory
|
|
122760
|
+
(moduleNameToDirectoryMap &&
|
|
122761
|
+
!ts.isExternalModuleNameRelative(name) &&
|
|
122762
|
+
((_c = (_b = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _b === void 0 ? void 0 : _b.get(ts.getModeAwareCacheKey(name, mode))) === null || _c === void 0 ? void 0 : _c.get(dirPath)));
|
|
122763
|
+
}, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath, name, mode, perDirResolutionCache) { var _a; return (_a = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(ancestorPath)) === null || _a === void 0 ? void 0 : _a.delete(name, mode); });
|
|
122141
122764
|
}
|
|
122142
122765
|
var BuilderProgramKind;
|
|
122143
122766
|
(function (BuilderProgramKind) {
|
|
@@ -122161,7 +122784,7 @@ var ts;
|
|
|
122161
122784
|
rootNames: newProgramOrRootNames,
|
|
122162
122785
|
options: hostOrOptions,
|
|
122163
122786
|
host: oldProgramOrHost,
|
|
122164
|
-
oldProgram: oldProgram
|
|
122787
|
+
oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
|
|
122165
122788
|
configFileParsingDiagnostics: configFileParsingDiagnostics,
|
|
122166
122789
|
projectReferences: projectReferences
|
|
122167
122790
|
});
|
|
@@ -122179,8 +122802,8 @@ var ts;
|
|
|
122179
122802
|
function getTextHandlingSourceMapForSignature(text, data) {
|
|
122180
122803
|
return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
|
|
122181
122804
|
}
|
|
122182
|
-
function computeSignatureWithDiagnostics(sourceFile, text,
|
|
122183
|
-
var _a;
|
|
122805
|
+
function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
|
|
122806
|
+
var _a, _b;
|
|
122184
122807
|
text = getTextHandlingSourceMapForSignature(text, data);
|
|
122185
122808
|
var sourceFileDirectory;
|
|
122186
122809
|
if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
|
|
@@ -122188,7 +122811,7 @@ var ts;
|
|
|
122188
122811
|
return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
|
|
122189
122812
|
}).join("\n");
|
|
122190
122813
|
}
|
|
122191
|
-
return (
|
|
122814
|
+
return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
|
|
122192
122815
|
function flattenDiagnosticMessageText(diagnostic) {
|
|
122193
122816
|
return ts.isString(diagnostic) ?
|
|
122194
122817
|
diagnostic :
|
|
@@ -122207,8 +122830,9 @@ var ts;
|
|
|
122207
122830
|
}
|
|
122208
122831
|
}
|
|
122209
122832
|
ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
|
|
122210
|
-
function computeSignature(text,
|
|
122211
|
-
|
|
122833
|
+
function computeSignature(text, host, data) {
|
|
122834
|
+
var _a;
|
|
122835
|
+
return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
|
|
122212
122836
|
}
|
|
122213
122837
|
ts.computeSignature = computeSignature;
|
|
122214
122838
|
function createBuilderProgram(kind, _a) {
|
|
@@ -122220,16 +122844,8 @@ var ts;
|
|
|
122220
122844
|
oldState = undefined;
|
|
122221
122845
|
return oldProgram;
|
|
122222
122846
|
}
|
|
122223
|
-
|
|
122224
|
-
|
|
122225
|
-
*/
|
|
122226
|
-
var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
|
|
122227
|
-
/**
|
|
122228
|
-
* Computing hash to for signature verification
|
|
122229
|
-
*/
|
|
122230
|
-
var computeHash = ts.maybeBind(host, host.createHash);
|
|
122231
|
-
var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
|
|
122232
|
-
newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
|
|
122847
|
+
var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
|
|
122848
|
+
newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
|
|
122233
122849
|
// To ensure that we arent storing any references to old program or new program without state
|
|
122234
122850
|
newProgram = undefined; // TODO: GH#18217
|
|
122235
122851
|
oldProgram = undefined;
|
|
@@ -122244,6 +122860,7 @@ var ts;
|
|
|
122244
122860
|
builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
|
|
122245
122861
|
builderProgram.emit = emit;
|
|
122246
122862
|
builderProgram.releaseProgram = function () { return releaseCache(state); };
|
|
122863
|
+
builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
|
|
122247
122864
|
if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
|
|
122248
122865
|
builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
|
|
122249
122866
|
}
|
|
@@ -122270,7 +122887,7 @@ var ts;
|
|
|
122270
122887
|
* in that order would be used to write the files
|
|
122271
122888
|
*/
|
|
122272
122889
|
function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
122273
|
-
var affected = getNextAffectedFile(state, cancellationToken,
|
|
122890
|
+
var affected = getNextAffectedFile(state, cancellationToken, host);
|
|
122274
122891
|
var emitKind = 1 /* Full */;
|
|
122275
122892
|
var isPendingEmitFile = false;
|
|
122276
122893
|
if (!affected) {
|
|
@@ -122316,7 +122933,7 @@ var ts;
|
|
|
122316
122933
|
var file = sourceFiles[0];
|
|
122317
122934
|
var info = state.fileInfos.get(file.resolvedPath);
|
|
122318
122935
|
if (info.signature === file.version) {
|
|
122319
|
-
var signature = computeSignatureWithDiagnostics(file, text,
|
|
122936
|
+
var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
|
|
122320
122937
|
// With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts
|
|
122321
122938
|
if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
|
|
122322
122939
|
emitSignature = signature;
|
|
@@ -122346,7 +122963,7 @@ var ts;
|
|
|
122346
122963
|
if (state.compilerOptions.composite) {
|
|
122347
122964
|
var filePath = sourceFiles[0].resolvedPath;
|
|
122348
122965
|
var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
|
|
122349
|
-
emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text,
|
|
122966
|
+
emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
|
|
122350
122967
|
// Dont write dts files if they didn't change
|
|
122351
122968
|
if (emitSignature === oldSignature)
|
|
122352
122969
|
return;
|
|
@@ -122356,7 +122973,7 @@ var ts;
|
|
|
122356
122973
|
}
|
|
122357
122974
|
}
|
|
122358
122975
|
else if (state.compilerOptions.composite) {
|
|
122359
|
-
var newSignature = computeSignature(text,
|
|
122976
|
+
var newSignature = computeSignature(text, host, data);
|
|
122360
122977
|
// Dont write dts files if they didn't change
|
|
122361
122978
|
if (newSignature === state.outSignature)
|
|
122362
122979
|
return;
|
|
@@ -122438,7 +123055,7 @@ var ts;
|
|
|
122438
123055
|
*/
|
|
122439
123056
|
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
|
|
122440
123057
|
while (true) {
|
|
122441
|
-
var affected = getNextAffectedFile(state, cancellationToken,
|
|
123058
|
+
var affected = getNextAffectedFile(state, cancellationToken, host);
|
|
122442
123059
|
if (!affected) {
|
|
122443
123060
|
// Done
|
|
122444
123061
|
return undefined;
|
|
@@ -122518,12 +123135,32 @@ var ts;
|
|
|
122518
123135
|
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
|
|
122519
123136
|
}
|
|
122520
123137
|
ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
|
|
122521
|
-
function
|
|
122522
|
-
var
|
|
122523
|
-
var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
|
|
122524
|
-
var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
|
|
122525
|
-
var state;
|
|
123138
|
+
function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
|
|
123139
|
+
var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
|
|
122526
123140
|
var filePaths;
|
|
123141
|
+
var fileAbsolutePaths;
|
|
123142
|
+
return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
|
|
123143
|
+
function toPath(path) {
|
|
123144
|
+
return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
|
|
123145
|
+
}
|
|
123146
|
+
function toAbsolutePath(path) {
|
|
123147
|
+
return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
|
|
123148
|
+
}
|
|
123149
|
+
function toFilePath(fileId) {
|
|
123150
|
+
var _a;
|
|
123151
|
+
return (_a = filePaths === null || filePaths === void 0 ? void 0 : filePaths[fileId - 1]) !== null && _a !== void 0 ? _a : ((filePaths !== null && filePaths !== void 0 ? filePaths : (filePaths = new Array(fileNames.length)))[fileId - 1] = toPath(fileNames[fileId - 1]));
|
|
123152
|
+
}
|
|
123153
|
+
function toFileAbsolutePath(fileId) {
|
|
123154
|
+
var _a;
|
|
123155
|
+
return (_a = fileAbsolutePaths === null || fileAbsolutePaths === void 0 ? void 0 : fileAbsolutePaths[fileId - 1]) !== null && _a !== void 0 ? _a : ((fileAbsolutePaths !== null && fileAbsolutePaths !== void 0 ? fileAbsolutePaths : (fileAbsolutePaths = new Array(fileNames.length)))[fileId - 1] = toAbsolutePath(fileNames[fileId - 1]));
|
|
123156
|
+
}
|
|
123157
|
+
}
|
|
123158
|
+
ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
|
|
123159
|
+
function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
|
|
123160
|
+
var _a, _b, _c;
|
|
123161
|
+
var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
|
|
123162
|
+
var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
|
|
123163
|
+
var state;
|
|
122527
123164
|
var filePathsSetList;
|
|
122528
123165
|
var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
|
|
122529
123166
|
if (isProgramBundleEmitBuildInfo(program)) {
|
|
@@ -122532,13 +123169,13 @@ var ts;
|
|
|
122532
123169
|
compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
|
|
122533
123170
|
latestChangedDtsFile: latestChangedDtsFile,
|
|
122534
123171
|
outSignature: program.outSignature,
|
|
123172
|
+
resuableCacheResolutions: toResuableCacheResolutions(),
|
|
122535
123173
|
};
|
|
122536
123174
|
}
|
|
122537
123175
|
else {
|
|
122538
|
-
|
|
122539
|
-
filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
|
|
123176
|
+
filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
|
|
122540
123177
|
var fileInfos_2 = new ts.Map();
|
|
122541
|
-
var emitSignatures_1 = ((
|
|
123178
|
+
var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
|
|
122542
123179
|
program.fileInfos.forEach(function (fileInfo, index) {
|
|
122543
123180
|
var path = toFilePath(index + 1);
|
|
122544
123181
|
var stateFileInfo = toBuilderStateFileInfo(fileInfo);
|
|
@@ -122546,7 +123183,7 @@ var ts;
|
|
|
122546
123183
|
if (emitSignatures_1 && stateFileInfo.signature)
|
|
122547
123184
|
emitSignatures_1.set(path, stateFileInfo.signature);
|
|
122548
123185
|
});
|
|
122549
|
-
(
|
|
123186
|
+
(_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
|
|
122550
123187
|
if (ts.isNumber(value))
|
|
122551
123188
|
emitSignatures_1.delete(toFilePath(value));
|
|
122552
123189
|
else
|
|
@@ -122565,14 +123202,17 @@ var ts;
|
|
|
122565
123202
|
changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
|
|
122566
123203
|
latestChangedDtsFile: latestChangedDtsFile,
|
|
122567
123204
|
emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
|
|
123205
|
+
resuableCacheResolutions: toResuableCacheResolutions(),
|
|
122568
123206
|
};
|
|
122569
123207
|
}
|
|
123208
|
+
state.compilerOptions.configFilePath = configFilePath;
|
|
122570
123209
|
return {
|
|
122571
123210
|
getState: function () { return state; },
|
|
122572
123211
|
saveEmitState: ts.noop,
|
|
122573
123212
|
restoreEmitState: ts.noop,
|
|
122574
123213
|
getProgram: ts.notImplemented,
|
|
122575
123214
|
getProgramOrUndefined: ts.returnUndefined,
|
|
123215
|
+
getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
|
|
122576
123216
|
releaseProgram: ts.noop,
|
|
122577
123217
|
getCompilerOptions: function () { return state.compilerOptions; },
|
|
122578
123218
|
getSourceFile: ts.notImplemented,
|
|
@@ -122592,15 +123232,6 @@ var ts;
|
|
|
122592
123232
|
close: ts.noop,
|
|
122593
123233
|
hasChangedEmitSignature: ts.returnFalse,
|
|
122594
123234
|
};
|
|
122595
|
-
function toPath(path) {
|
|
122596
|
-
return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
|
|
122597
|
-
}
|
|
122598
|
-
function toAbsolutePath(path) {
|
|
122599
|
-
return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
|
|
122600
|
-
}
|
|
122601
|
-
function toFilePath(fileId) {
|
|
122602
|
-
return filePaths[fileId - 1];
|
|
122603
|
-
}
|
|
122604
123235
|
function toFilePathsSet(fileIdsListId) {
|
|
122605
123236
|
return filePathsSetList[fileIdsListId - 1];
|
|
122606
123237
|
}
|
|
@@ -122615,8 +123246,249 @@ var ts;
|
|
|
122615
123246
|
});
|
|
122616
123247
|
return map;
|
|
122617
123248
|
}
|
|
123249
|
+
function toResuableCacheResolutions() {
|
|
123250
|
+
return program.cacheResolutions && {
|
|
123251
|
+
cache: program.cacheResolutions,
|
|
123252
|
+
getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
|
|
123253
|
+
};
|
|
123254
|
+
}
|
|
122618
123255
|
}
|
|
122619
123256
|
ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
|
|
123257
|
+
function createGetProgramOrOldBuildInfoProgramUndefined(state) {
|
|
123258
|
+
return function () {
|
|
123259
|
+
var _a;
|
|
123260
|
+
return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
|
|
123261
|
+
(function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions,
|
|
123262
|
+
// Prefer cached resolutions over serialized format
|
|
123263
|
+
!state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
|
|
123264
|
+
undefined);
|
|
123265
|
+
};
|
|
123266
|
+
}
|
|
123267
|
+
function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
|
|
123268
|
+
if (!cacheResolutions && !resuableCacheResolutions)
|
|
123269
|
+
return undefined;
|
|
123270
|
+
var fileExistsMap = new ts.Map();
|
|
123271
|
+
var packageJsonInfoMap = new ts.Map();
|
|
123272
|
+
var affectingLoationsSameMap = new ts.Map();
|
|
123273
|
+
var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
|
|
123274
|
+
var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
|
|
123275
|
+
var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
|
|
123276
|
+
var decodedPackageJsonMap;
|
|
123277
|
+
var packageJsonScopes;
|
|
123278
|
+
var decodedHashes;
|
|
123279
|
+
var resolutions;
|
|
123280
|
+
var originalPathOrResolvedFileNames;
|
|
123281
|
+
var resolutionEntries;
|
|
123282
|
+
return {
|
|
123283
|
+
getCompilerOptions: function () { return compilerOptions; },
|
|
123284
|
+
getResolvedModule: function (dirPath, name, mode, redirectedReference) { return getResolvedFromCache(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules, resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.modules, decodedResolvedModules, dirPath, name, mode, redirectedReference, cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap); },
|
|
123285
|
+
getResolvedTypeReferenceDirective: function (dirPath, name, mode, redirectedReference) { return getResolvedFromCache(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs, resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.typeRefs, decodedResolvedTypeRefs, dirPath, name, mode, redirectedReference,
|
|
123286
|
+
/*moduleNameToDirectoryMap*/ undefined,
|
|
123287
|
+
/*decodedModuleNameToDirectoryMap*/ undefined); },
|
|
123288
|
+
getPackageJsonScope: getPackageJsonScope,
|
|
123289
|
+
};
|
|
123290
|
+
function fileExists(fileName) {
|
|
123291
|
+
var result = fileExistsMap.get(fileName);
|
|
123292
|
+
if (result === undefined)
|
|
123293
|
+
fileExistsMap.set(fileName, result = host.fileExists(fileName));
|
|
123294
|
+
return result;
|
|
123295
|
+
}
|
|
123296
|
+
function getPackageJsonInfo(fileName) {
|
|
123297
|
+
var result = packageJsonInfoMap.get(fileName);
|
|
123298
|
+
if (result === undefined)
|
|
123299
|
+
packageJsonInfoMap.set(fileName, result = host.getPackageJsonInfo(fileName) || false);
|
|
123300
|
+
return result || undefined;
|
|
123301
|
+
}
|
|
123302
|
+
function affectingLocationsSame(fileName, expected) {
|
|
123303
|
+
var _a;
|
|
123304
|
+
var result = affectingLoationsSameMap.get(fileName);
|
|
123305
|
+
if (result !== undefined)
|
|
123306
|
+
return result;
|
|
123307
|
+
var packageJsonInfo = getPackageJsonInfo(fileName);
|
|
123308
|
+
var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
|
|
123309
|
+
if (ts.isString(expected)) {
|
|
123310
|
+
result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
|
|
123311
|
+
}
|
|
123312
|
+
else {
|
|
123313
|
+
var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
|
|
123314
|
+
result = currentText === expectedText;
|
|
123315
|
+
}
|
|
123316
|
+
affectingLoationsSameMap.set(fileName, result);
|
|
123317
|
+
return result;
|
|
123318
|
+
}
|
|
123319
|
+
function getPackageJsonScope(dirPath) {
|
|
123320
|
+
var _a;
|
|
123321
|
+
var fromCache = (_a = cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.dirToPackageJsonScope) === null || _a === void 0 ? void 0 : _a.get(dirPath);
|
|
123322
|
+
if (fromCache) {
|
|
123323
|
+
var packageJson = ts.getPackageJsconLocationFromScope(fromCache);
|
|
123324
|
+
var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(packageJson);
|
|
123325
|
+
if (result === undefined) {
|
|
123326
|
+
(packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map())).set(packageJson, result = affectingLocationsSame(packageJson, fromCache.info) ?
|
|
123327
|
+
fromCache :
|
|
123328
|
+
fileExists(packageJson) ?
|
|
123329
|
+
{ info: getPackageJsonInfo(packageJson), affectingLocations: [packageJson] } :
|
|
123330
|
+
false);
|
|
123331
|
+
}
|
|
123332
|
+
return result || undefined;
|
|
123333
|
+
}
|
|
123334
|
+
if (!(resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.packageJsons))
|
|
123335
|
+
return;
|
|
123336
|
+
if (!decodedPackageJsonMap) {
|
|
123337
|
+
decodedPackageJsonMap = new ts.Map();
|
|
123338
|
+
var filePathDecoder_1 = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder();
|
|
123339
|
+
for (var _i = 0, _b = resuableCacheResolutions.cache.packageJsons; _i < _b.length; _i++) {
|
|
123340
|
+
var dirIdOrDirAndPackageJson = _b[_i];
|
|
123341
|
+
var dirPath_1 = filePathDecoder_1.toFilePath(dirIdOrDirAndPackageJson[0]);
|
|
123342
|
+
var packageJson = filePathDecoder_1.toFileAbsolutePath(dirIdOrDirAndPackageJson[1]);
|
|
123343
|
+
ts.moduleNameToDirectorySet(decodedPackageJsonMap, dirPath_1, packageJson, ts.identity, function (fileName) { return ts.toPath(fileName, filePathDecoder_1.currentDirectory, filePathDecoder_1.getCanonicalFileName); }, ts.noop);
|
|
123344
|
+
}
|
|
123345
|
+
}
|
|
123346
|
+
return toPackageJsonScope(decodedPackageJsonMap.get(dirPath));
|
|
123347
|
+
}
|
|
123348
|
+
function toPackageJsonScope(file) {
|
|
123349
|
+
if (!file)
|
|
123350
|
+
return undefined;
|
|
123351
|
+
var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(file);
|
|
123352
|
+
if (result !== undefined)
|
|
123353
|
+
return result || undefined;
|
|
123354
|
+
(packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map()));
|
|
123355
|
+
if (fileExists(file)) {
|
|
123356
|
+
result = {
|
|
123357
|
+
info: getPackageJsonInfo(file),
|
|
123358
|
+
affectingLocations: [file]
|
|
123359
|
+
};
|
|
123360
|
+
}
|
|
123361
|
+
packageJsonScopes.set(file, result || false);
|
|
123362
|
+
return result;
|
|
123363
|
+
}
|
|
123364
|
+
function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
|
|
123365
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
123366
|
+
// If we are using the cache, directly get from there
|
|
123367
|
+
var fromCache = ((_b = (_a = cache === null || cache === void 0 ? void 0 : cache.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(dirPath)) === null || _b === void 0 ? void 0 : _b.get(name, mode)) ||
|
|
123368
|
+
((_d = (_c = moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath));
|
|
123369
|
+
if (fromCache) {
|
|
123370
|
+
return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
|
|
123371
|
+
fromCache.resolvedTypeReferenceDirective.resolvedFileName) && ts.every(fromCache.affectingLocations, function (fileName) { var _a; return affectingLocationsSame(fileName, (_a = cacheResolutions.packageJsonCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(fileName)); }) ? fromCache : undefined;
|
|
123372
|
+
}
|
|
123373
|
+
if (!reusableCache)
|
|
123374
|
+
return undefined;
|
|
123375
|
+
// Decode so we have maps for directories
|
|
123376
|
+
if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
|
|
123377
|
+
if (ts.isArray(reusableCache)) {
|
|
123378
|
+
setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, /*optionsKey*/ undefined, reusableCache, decodedModuleNameToDirectoryMap);
|
|
123379
|
+
}
|
|
123380
|
+
else {
|
|
123381
|
+
if (reusableCache.own)
|
|
123382
|
+
setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, /*optionsKey*/ undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
|
|
123383
|
+
reusableCache.redirects.forEach(function (_a) {
|
|
123384
|
+
var options = _a.options, cache = _a.cache;
|
|
123385
|
+
var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
|
|
123386
|
+
setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
|
|
123387
|
+
});
|
|
123388
|
+
}
|
|
123389
|
+
// Ensure redirected reference verifies options before using redirects map
|
|
123390
|
+
decodedReusableCache.clearRedirectsMap();
|
|
123391
|
+
decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
|
|
123392
|
+
}
|
|
123393
|
+
var resolutionId = ((_g = (_f = decodedReusableCache.getMapOfCacheRedirects(redirectedReference)) === null || _f === void 0 ? void 0 : _f.get(dirPath)) === null || _g === void 0 ? void 0 : _g.get(name, mode)) ||
|
|
123394
|
+
((_j = (_h = decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _h === void 0 ? void 0 : _h.get(ts.getModeAwareCacheKey(name, mode))) === null || _j === void 0 ? void 0 : _j.get(dirPath));
|
|
123395
|
+
return resolutionId ? toResolution(resolutionId) : undefined;
|
|
123396
|
+
}
|
|
123397
|
+
function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
|
|
123398
|
+
var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
|
|
123399
|
+
reusableCache.forEach(function (_a) {
|
|
123400
|
+
var dirId = _a[0], entryId = _a[1];
|
|
123401
|
+
var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
|
|
123402
|
+
map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
|
|
123403
|
+
});
|
|
123404
|
+
}
|
|
123405
|
+
function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
|
|
123406
|
+
var modeAwareCache = ts.createModeAwareCache();
|
|
123407
|
+
entries.forEach(function (entryId) {
|
|
123408
|
+
var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
|
|
123409
|
+
modeAwareCache.set(name, mode, resolutionId);
|
|
123410
|
+
if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
|
|
123411
|
+
return;
|
|
123412
|
+
var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
|
|
123413
|
+
var key = ts.getModeAwareCacheKey(name, mode);
|
|
123414
|
+
var moduleNameMap = mapForOptions.get(key);
|
|
123415
|
+
;
|
|
123416
|
+
if (!moduleNameMap)
|
|
123417
|
+
mapForOptions.set(key, moduleNameMap = new ts.Map());
|
|
123418
|
+
ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
|
|
123419
|
+
});
|
|
123420
|
+
return modeAwareCache;
|
|
123421
|
+
}
|
|
123422
|
+
function toResolutionEntry(entryId) {
|
|
123423
|
+
var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
|
|
123424
|
+
if (existing)
|
|
123425
|
+
return existing;
|
|
123426
|
+
resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
|
|
123427
|
+
var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
|
|
123428
|
+
return resolutionEntries[entryId - 1] = [
|
|
123429
|
+
toName(nameId),
|
|
123430
|
+
resolutionId,
|
|
123431
|
+
mode
|
|
123432
|
+
];
|
|
123433
|
+
}
|
|
123434
|
+
function toName(nameId) {
|
|
123435
|
+
return resuableCacheResolutions.cache.names[nameId - 1];
|
|
123436
|
+
}
|
|
123437
|
+
function toOriginalPathOrResolvedFileName(resolutionId) {
|
|
123438
|
+
var _a;
|
|
123439
|
+
return (_a = originalPathOrResolvedFileNames === null || originalPathOrResolvedFileNames === void 0 ? void 0 : originalPathOrResolvedFileNames[resolutionId - 1]) !== null && _a !== void 0 ? _a : ((originalPathOrResolvedFileNames !== null && originalPathOrResolvedFileNames !== void 0 ? originalPathOrResolvedFileNames : (originalPathOrResolvedFileNames = new Array(resuableCacheResolutions.cache.resolutions.length)))[resolutionId - 1] = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.originalPath ||
|
|
123440
|
+
resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
|
|
123441
|
+
}
|
|
123442
|
+
function toAffectingFileLocation(fileId) {
|
|
123443
|
+
if (!decodedHashes && resuableCacheResolutions.cache.hash) {
|
|
123444
|
+
decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
|
|
123445
|
+
}
|
|
123446
|
+
var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
|
|
123447
|
+
var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
|
|
123448
|
+
return affectingLocationsSame(file, hash) ? file : undefined;
|
|
123449
|
+
}
|
|
123450
|
+
function toResolution(resolutionId) {
|
|
123451
|
+
var _a, _b;
|
|
123452
|
+
var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
|
|
123453
|
+
if (existing !== undefined)
|
|
123454
|
+
return existing || undefined;
|
|
123455
|
+
resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
|
|
123456
|
+
var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
|
|
123457
|
+
var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
|
|
123458
|
+
var affectingLocations;
|
|
123459
|
+
if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
|
|
123460
|
+
var file = toAffectingFileLocation(fileId);
|
|
123461
|
+
if (file)
|
|
123462
|
+
(affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
|
|
123463
|
+
return !!file;
|
|
123464
|
+
})) {
|
|
123465
|
+
// Type Ref doesnt need extension
|
|
123466
|
+
var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
|
|
123467
|
+
return resolutions[resolutionId - 1] = {
|
|
123468
|
+
resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
|
|
123469
|
+
resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
|
|
123470
|
+
failedLookupLocations: ts.emptyArray,
|
|
123471
|
+
affectingLocations: affectingLocations,
|
|
123472
|
+
resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
|
|
123473
|
+
};
|
|
123474
|
+
}
|
|
123475
|
+
resolutions[resolutionId - 1] = false;
|
|
123476
|
+
return undefined;
|
|
123477
|
+
}
|
|
123478
|
+
function toResolved(resolved, resolvedFileName, extension) {
|
|
123479
|
+
if (!resolved)
|
|
123480
|
+
return undefined;
|
|
123481
|
+
return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
|
|
123482
|
+
}
|
|
123483
|
+
function toResolutionDiagnostic(d) {
|
|
123484
|
+
return {
|
|
123485
|
+
isImports: !!d.isImports,
|
|
123486
|
+
entry: d.entry || "",
|
|
123487
|
+
packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
|
|
123488
|
+
};
|
|
123489
|
+
}
|
|
123490
|
+
}
|
|
123491
|
+
ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
|
|
122620
123492
|
function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
|
|
122621
123493
|
var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
|
|
122622
123494
|
var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
|
|
@@ -122636,6 +123508,7 @@ var ts;
|
|
|
122636
123508
|
restoreEmitState: ts.noop,
|
|
122637
123509
|
getProgram: getProgram,
|
|
122638
123510
|
getProgramOrUndefined: function () { return getState().program; },
|
|
123511
|
+
getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
|
|
122639
123512
|
releaseProgram: function () { return getState().program = undefined; },
|
|
122640
123513
|
getCompilerOptions: function () { return getState().compilerOptions; },
|
|
122641
123514
|
getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
|
|
@@ -122731,15 +123604,57 @@ var ts;
|
|
|
122731
123604
|
return true;
|
|
122732
123605
|
}
|
|
122733
123606
|
ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
|
|
123607
|
+
function getResolvedModuleOfResolution(resolution) {
|
|
123608
|
+
return resolution.resolvedModule;
|
|
123609
|
+
}
|
|
123610
|
+
ts.getResolvedModuleOfResolution = getResolvedModuleOfResolution;
|
|
123611
|
+
function getResolvedTypeReferenceDirectiveOfResolution(resolution) {
|
|
123612
|
+
return resolution.resolvedTypeReferenceDirective;
|
|
123613
|
+
}
|
|
123614
|
+
ts.getResolvedTypeReferenceDirectiveOfResolution = getResolvedTypeReferenceDirectiveOfResolution;
|
|
123615
|
+
function toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, onRedirectedReferenceKey, forEachResolution, toPath, ancestoryWorker) {
|
|
123616
|
+
if (!(fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()))
|
|
123617
|
+
return perDirCache;
|
|
123618
|
+
var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
|
|
123619
|
+
var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
|
|
123620
|
+
var options = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
|
|
123621
|
+
var key = ts.getRedirectsCacheKey(options);
|
|
123622
|
+
onRedirectedReferenceKey(key);
|
|
123623
|
+
var dirPath = ts.getDirectoryPath(path);
|
|
123624
|
+
var perDirResolutionCache = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
|
|
123625
|
+
var cacheForDir = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
|
|
123626
|
+
fileCacheFromProgram.forEach(function (r, name, mode) {
|
|
123627
|
+
if (forEachResolution(r, name, mode, key, redirectedReference, dirPath))
|
|
123628
|
+
return;
|
|
123629
|
+
if (cacheForDir === null || cacheForDir === void 0 ? void 0 : cacheForDir.has(name, mode))
|
|
123630
|
+
return;
|
|
123631
|
+
if (!cacheForDir) {
|
|
123632
|
+
perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options, key));
|
|
123633
|
+
perDirResolutionCache.set(dirPath, cacheForDir = ts.createModeAwareCache());
|
|
123634
|
+
}
|
|
123635
|
+
cacheForDir.set(name, mode, r);
|
|
123636
|
+
if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
|
|
123637
|
+
return;
|
|
123638
|
+
var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options, key);
|
|
123639
|
+
var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
|
|
123640
|
+
var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
|
|
123641
|
+
if (!directoryPathMap)
|
|
123642
|
+
actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
|
|
123643
|
+
ts.moduleNameToDirectorySet(directoryPathMap, dirPath, r, ts.getResolvedFileNameForModuleNameToDirectorySet, toPath, function (ancestorPath) { return ancestoryWorker(ancestorPath, name, mode, perDirResolutionCache); });
|
|
123644
|
+
});
|
|
123645
|
+
return perDirCache;
|
|
123646
|
+
}
|
|
123647
|
+
ts.toPerDirectoryResolution = toPerDirectoryResolution;
|
|
122734
123648
|
function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
|
|
122735
123649
|
var filesWithChangedSetOfUnresolvedImports;
|
|
122736
123650
|
var filesWithInvalidatedResolutions;
|
|
122737
|
-
var filesWithInvalidatedNonRelativeUnresolvedImports;
|
|
122738
|
-
var nonRelativeExternalModuleResolutions = ts.createMultiMap();
|
|
122739
123651
|
var resolutionsWithFailedLookups = [];
|
|
122740
123652
|
var resolutionsWithOnlyAffectingLocations = [];
|
|
122741
123653
|
var resolvedFileToResolution = ts.createMultiMap();
|
|
122742
|
-
var
|
|
123654
|
+
var perFilePackageJsonScope = new ts.Map();
|
|
123655
|
+
var watchedPackageJsonScopes = [];
|
|
123656
|
+
var packageJsonsToCloseWatcherOn;
|
|
123657
|
+
var resolutionsToCloseWatcherOn;
|
|
122743
123658
|
var hasChangedAutomaticTypeDirectiveNames = false;
|
|
122744
123659
|
var affectingPathChecksForFile;
|
|
122745
123660
|
var affectingPathChecks;
|
|
@@ -122748,18 +123663,16 @@ var ts;
|
|
|
122748
123663
|
var isInDirectoryChecks;
|
|
122749
123664
|
var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217
|
|
122750
123665
|
var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
|
|
123666
|
+
var oldModuleAndTypeRefCache;
|
|
123667
|
+
var oldPackageJsonInfoCache;
|
|
122751
123668
|
// The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file.
|
|
122752
123669
|
// The key in the map is source file's path.
|
|
122753
123670
|
// The values are Map of resolutions with key being name lookedup.
|
|
122754
123671
|
var resolvedModuleNames = new ts.Map();
|
|
122755
|
-
var
|
|
122756
|
-
var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
|
|
122757
|
-
var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName,
|
|
122758
|
-
/*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
|
|
123672
|
+
var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
|
|
122759
123673
|
var resolvedTypeReferenceDirectives = new ts.Map();
|
|
122760
|
-
var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
|
|
122761
123674
|
var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName,
|
|
122762
|
-
/*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache()
|
|
123675
|
+
/*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache());
|
|
122763
123676
|
/**
|
|
122764
123677
|
* These are the extensions that failed lookup files will have by default,
|
|
122765
123678
|
* any other extension of failed lookup will be store that path in custom failed lookup path
|
|
@@ -122776,34 +123689,23 @@ var ts;
|
|
|
122776
123689
|
// TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames
|
|
122777
123690
|
var typeRootsWatches = new ts.Map();
|
|
122778
123691
|
return {
|
|
123692
|
+
resolvedModuleNames: resolvedModuleNames,
|
|
123693
|
+
resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
|
|
122779
123694
|
getModuleResolutionCache: function () { return moduleResolutionCache; },
|
|
123695
|
+
getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
|
|
122780
123696
|
startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
|
|
122781
123697
|
finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
|
|
122782
|
-
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122783
|
-
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122784
123698
|
startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
|
|
122785
123699
|
finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
|
|
122786
123700
|
resolveModuleNames: resolveModuleNames,
|
|
122787
|
-
getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
|
|
122788
123701
|
resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
|
|
122789
|
-
removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
|
|
122790
|
-
removeResolutionsOfFile: removeResolutionsOfFile,
|
|
122791
123702
|
hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
|
|
122792
123703
|
invalidateResolutionOfFile: invalidateResolutionOfFile,
|
|
122793
123704
|
invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
|
|
122794
123705
|
setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
|
|
122795
123706
|
createHasInvalidatedResolution: createHasInvalidatedResolution,
|
|
122796
|
-
isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
|
|
122797
|
-
updateTypeRootsWatch: updateTypeRootsWatch,
|
|
122798
|
-
closeTypeRootsWatch: closeTypeRootsWatch,
|
|
122799
123707
|
clear: clear
|
|
122800
123708
|
};
|
|
122801
|
-
function getResolvedModule(resolution) {
|
|
122802
|
-
return resolution.resolvedModule;
|
|
122803
|
-
}
|
|
122804
|
-
function getResolvedTypeReferenceDirective(resolution) {
|
|
122805
|
-
return resolution.resolvedTypeReferenceDirective;
|
|
122806
|
-
}
|
|
122807
123709
|
function isInDirectoryPath(dir, file) {
|
|
122808
123710
|
if (dir === undefined || file.length <= dir.length) {
|
|
122809
123711
|
return false;
|
|
@@ -122814,21 +123716,25 @@ var ts;
|
|
|
122814
123716
|
ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
|
|
122815
123717
|
ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
|
|
122816
123718
|
customFailedLookupPaths.clear();
|
|
122817
|
-
nonRelativeExternalModuleResolutions.clear();
|
|
122818
123719
|
closeTypeRootsWatch();
|
|
122819
123720
|
resolvedModuleNames.clear();
|
|
122820
123721
|
resolvedTypeReferenceDirectives.clear();
|
|
122821
123722
|
resolvedFileToResolution.clear();
|
|
122822
123723
|
resolutionsWithFailedLookups.length = 0;
|
|
122823
123724
|
resolutionsWithOnlyAffectingLocations.length = 0;
|
|
123725
|
+
watchedPackageJsonScopes.length = 0;
|
|
122824
123726
|
failedLookupChecks = undefined;
|
|
122825
123727
|
startsWithPathChecks = undefined;
|
|
122826
123728
|
isInDirectoryChecks = undefined;
|
|
122827
123729
|
affectingPathChecks = undefined;
|
|
122828
123730
|
affectingPathChecksForFile = undefined;
|
|
123731
|
+
resolutionsToCloseWatcherOn = undefined;
|
|
123732
|
+
packageJsonsToCloseWatcherOn = undefined;
|
|
123733
|
+
oldModuleAndTypeRefCache = undefined;
|
|
123734
|
+
oldPackageJsonInfoCache = undefined;
|
|
122829
123735
|
moduleResolutionCache.clear();
|
|
122830
123736
|
typeReferenceDirectiveResolutionCache.clear();
|
|
122831
|
-
|
|
123737
|
+
perFilePackageJsonScope.clear();
|
|
122832
123738
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
122833
123739
|
}
|
|
122834
123740
|
function startRecordingFilesWithChangedResolutions() {
|
|
@@ -122839,14 +123745,6 @@ var ts;
|
|
|
122839
123745
|
filesWithChangedSetOfUnresolvedImports = undefined;
|
|
122840
123746
|
return collected;
|
|
122841
123747
|
}
|
|
122842
|
-
function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
|
|
122843
|
-
if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
|
|
122844
|
-
return false;
|
|
122845
|
-
}
|
|
122846
|
-
// Invalidated if file has unresolved imports
|
|
122847
|
-
var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
|
|
122848
|
-
return !!value && !!value.length;
|
|
122849
|
-
}
|
|
122850
123748
|
function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
|
|
122851
123749
|
// Ensure pending resolutions are applied
|
|
122852
123750
|
invalidateResolutionsOfFailedLookupLocations();
|
|
@@ -122857,63 +123755,232 @@ var ts;
|
|
|
122857
123755
|
}
|
|
122858
123756
|
var collected = filesWithInvalidatedResolutions;
|
|
122859
123757
|
filesWithInvalidatedResolutions = undefined;
|
|
122860
|
-
return function (path) { return (
|
|
122861
|
-
isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
|
|
123758
|
+
return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
|
|
122862
123759
|
}
|
|
122863
123760
|
function startCachingPerDirectoryResolution() {
|
|
122864
|
-
moduleResolutionCache.
|
|
122865
|
-
|
|
122866
|
-
|
|
122867
|
-
|
|
122868
|
-
|
|
122869
|
-
|
|
123761
|
+
var packageJsonInfoCache = moduleResolutionCache.getPackageJsonInfoCache();
|
|
123762
|
+
var internalCache = packageJsonInfoCache.getInternalMap();
|
|
123763
|
+
moduleResolutionCache.clear();
|
|
123764
|
+
typeReferenceDirectiveResolutionCache.clear();
|
|
123765
|
+
moduleResolutionCache.update(resolutionHost.getCompilationSettings());
|
|
123766
|
+
typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
|
|
123767
|
+
if (oldModuleAndTypeRefCache) {
|
|
123768
|
+
oldModuleAndTypeRefCache.clearRedirectsMap();
|
|
123769
|
+
moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
|
|
123770
|
+
typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
|
|
123771
|
+
}
|
|
123772
|
+
packageJsonInfoCache.setInternalMap(internalCache);
|
|
123773
|
+
packageJsonInfoCache.setOldPackageJsonScopeCache(oldPackageJsonInfoCache);
|
|
122870
123774
|
}
|
|
122871
123775
|
function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
|
|
122872
|
-
|
|
122873
|
-
|
|
122874
|
-
|
|
122875
|
-
|
|
122876
|
-
|
|
122877
|
-
|
|
122878
|
-
|
|
122879
|
-
|
|
122880
|
-
|
|
122881
|
-
|
|
122882
|
-
|
|
123776
|
+
hasChangedAutomaticTypeDirectiveNames = false;
|
|
123777
|
+
if (!newProgram) {
|
|
123778
|
+
clear();
|
|
123779
|
+
return;
|
|
123780
|
+
}
|
|
123781
|
+
if (newProgram === oldProgram)
|
|
123782
|
+
return;
|
|
123783
|
+
var needsResolutionUpdate = newProgram.structureIsReused !== 3 /* Completely */;
|
|
123784
|
+
var modules;
|
|
123785
|
+
var typeRefs;
|
|
123786
|
+
var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
|
|
123787
|
+
var dirToPackageJsonScope = new ts.Map();
|
|
123788
|
+
for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
|
|
123789
|
+
var newFile = _a[_i];
|
|
123790
|
+
if (needsResolutionUpdate) {
|
|
123791
|
+
modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, newFile.resolvedModules, newFile, getResolvedModuleOfResolution, modules, moduleNameToDirectoryMap);
|
|
123792
|
+
typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newFile.resolvedTypeReferenceDirectiveNames, newFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs,
|
|
123793
|
+
/*moduleNameToDirectoryMap*/ undefined);
|
|
123794
|
+
}
|
|
123795
|
+
ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope);
|
|
123796
|
+
}
|
|
123797
|
+
if (needsResolutionUpdate) {
|
|
123798
|
+
var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
|
|
123799
|
+
typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs,
|
|
123800
|
+
/*moduleNameToDirectoryMap*/ undefined);
|
|
123801
|
+
if (!modules && !typeRefs) {
|
|
123802
|
+
oldModuleAndTypeRefCache = undefined;
|
|
123803
|
+
}
|
|
123804
|
+
else {
|
|
123805
|
+
oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
|
|
123806
|
+
}
|
|
123807
|
+
// Remove resolutions for files not in the program
|
|
123808
|
+
if (oldProgram) {
|
|
123809
|
+
for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
|
|
123810
|
+
var f = _c[_b];
|
|
123811
|
+
if (!newProgram.getSourceFileByPath(f.path))
|
|
123812
|
+
removeResolutionsOfFile(f.path);
|
|
122883
123813
|
}
|
|
122884
|
-
|
|
122885
|
-
|
|
122886
|
-
|
|
122887
|
-
}
|
|
123814
|
+
var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
|
|
123815
|
+
if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
|
|
123816
|
+
removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
|
|
122888
123817
|
}
|
|
122889
|
-
|
|
122890
|
-
impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
|
|
122891
|
-
else
|
|
122892
|
-
impliedFormatPackageJsons.delete(newFile.path);
|
|
122893
|
-
});
|
|
122894
|
-
impliedFormatPackageJsons.forEach(function (existing, path) {
|
|
122895
|
-
if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
|
|
122896
|
-
existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
|
|
122897
|
-
impliedFormatPackageJsons.delete(path);
|
|
122898
|
-
}
|
|
122899
|
-
});
|
|
123818
|
+
}
|
|
122900
123819
|
}
|
|
122901
|
-
|
|
122902
|
-
if (
|
|
122903
|
-
|
|
122904
|
-
|
|
123820
|
+
perFilePackageJsonScope.forEach(function (existing, path) {
|
|
123821
|
+
if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
|
|
123822
|
+
stopWatchingPackageJsonScope(existing, path);
|
|
123823
|
+
perFilePackageJsonScope.delete(path);
|
|
122905
123824
|
}
|
|
122906
123825
|
});
|
|
123826
|
+
if (dirToPackageJsonScope.size) {
|
|
123827
|
+
oldPackageJsonInfoCache = getOldPackageJsonInfoCache(dirToPackageJsonScope);
|
|
123828
|
+
}
|
|
123829
|
+
else {
|
|
123830
|
+
oldPackageJsonInfoCache = undefined;
|
|
123831
|
+
}
|
|
123832
|
+
if (needsResolutionUpdate && (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions()))
|
|
123833
|
+
updateTypeRootsWatch();
|
|
123834
|
+
// Remove symlinked watchers that have zero ref count
|
|
123835
|
+
resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
|
|
123836
|
+
resolutionsToCloseWatcherOn = undefined;
|
|
123837
|
+
packageJsonsToCloseWatcherOn === null || packageJsonsToCloseWatcherOn === void 0 ? void 0 : packageJsonsToCloseWatcherOn.forEach(closeWatchersOfPackageJsonScope);
|
|
123838
|
+
packageJsonsToCloseWatcherOn = undefined;
|
|
122907
123839
|
fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
|
|
122908
123840
|
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122909
123841
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122910
123842
|
watcher.watcher.close();
|
|
122911
123843
|
}
|
|
122912
123844
|
});
|
|
122913
|
-
hasChangedAutomaticTypeDirectiveNames = false;
|
|
122914
123845
|
}
|
|
122915
|
-
function
|
|
123846
|
+
function ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope) {
|
|
123847
|
+
var _a;
|
|
123848
|
+
var existing = perFilePackageJsonScope.get(newFile.path);
|
|
123849
|
+
var scope = ts.isExternalOrCommonJsModule(newFile) ? newFile.packageJsonScope : undefined;
|
|
123850
|
+
if (scope) {
|
|
123851
|
+
((_a = scope.files) !== null && _a !== void 0 ? _a : (scope.files = new ts.Set())).add(newFile.path);
|
|
123852
|
+
watchPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
|
|
123853
|
+
watchPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
|
|
123854
|
+
perFilePackageJsonScope.set(newFile.path, scope);
|
|
123855
|
+
ts.moduleNameToDirectorySet(dirToPackageJsonScope, ts.getDirectoryPath(newFile.resolvedPath), scope, ts.getPackageJsconLocationFromScope, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
|
|
123856
|
+
}
|
|
123857
|
+
if (existing && scope !== existing)
|
|
123858
|
+
stopWatchingPackageJsonScope(existing, newFile.path);
|
|
123859
|
+
}
|
|
123860
|
+
function stopWatchingPackageJsonScope(scope, path) {
|
|
122916
123861
|
var _a, _b;
|
|
123862
|
+
(_a = scope.files) === null || _a === void 0 ? void 0 : _a.delete(path);
|
|
123863
|
+
if (!((_b = scope.files) === null || _b === void 0 ? void 0 : _b.size))
|
|
123864
|
+
(packageJsonsToCloseWatcherOn !== null && packageJsonsToCloseWatcherOn !== void 0 ? packageJsonsToCloseWatcherOn : (packageJsonsToCloseWatcherOn = [])).push(scope);
|
|
123865
|
+
}
|
|
123866
|
+
function watchPackageJsonScopeLocations(scope, locations, field) {
|
|
123867
|
+
var _a, _b;
|
|
123868
|
+
var locationsLength = (_a = locations === null || locations === void 0 ? void 0 : locations.length) !== null && _a !== void 0 ? _a : 0;
|
|
123869
|
+
if (!locationsLength || scope[field] === locationsLength)
|
|
123870
|
+
return;
|
|
123871
|
+
if (!scope.watchedFailed && !scope.watchedAffected)
|
|
123872
|
+
watchedPackageJsonScopes.push(scope);
|
|
123873
|
+
for (var i = (_b = scope[field]) !== null && _b !== void 0 ? _b : 0; i < locationsLength; i++) {
|
|
123874
|
+
createFileWatcherOfAffectingLocation(locations[i], /*forResolution*/ false);
|
|
123875
|
+
}
|
|
123876
|
+
scope[field] = locationsLength;
|
|
123877
|
+
}
|
|
123878
|
+
function closeWatchersOfPackageJsonScope(scope) {
|
|
123879
|
+
var _a;
|
|
123880
|
+
// Either in use or already closed, skip
|
|
123881
|
+
if (((_a = scope.files) === null || _a === void 0 ? void 0 : _a.size) || !scope.files)
|
|
123882
|
+
return;
|
|
123883
|
+
scope.files = undefined;
|
|
123884
|
+
ts.unorderedRemoveItem(watchedPackageJsonScopes, scope);
|
|
123885
|
+
stopWatchingPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
|
|
123886
|
+
stopWatchingPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
|
|
123887
|
+
}
|
|
123888
|
+
function stopWatchingPackageJsonScopeLocations(scope, locations, field) {
|
|
123889
|
+
if (!scope[field])
|
|
123890
|
+
return;
|
|
123891
|
+
for (var i = 0; i < scope[field]; i++) {
|
|
123892
|
+
fileWatchesOfAffectingLocations.get(locations[i]).files--;
|
|
123893
|
+
}
|
|
123894
|
+
scope[field] = undefined;
|
|
123895
|
+
}
|
|
123896
|
+
function getOldPackageJsonInfoCache(dirToPackageJsonScope) {
|
|
123897
|
+
var packageJsons;
|
|
123898
|
+
return {
|
|
123899
|
+
getPackageJsonScope: function (dir) {
|
|
123900
|
+
var _a;
|
|
123901
|
+
var scope = dirToPackageJsonScope.get(dir);
|
|
123902
|
+
if (!scope)
|
|
123903
|
+
return undefined;
|
|
123904
|
+
if (!scope.isInvalidated)
|
|
123905
|
+
return scope;
|
|
123906
|
+
if (!resolutionHost.getCompilationSettings().cacheResolutions || !scope.info)
|
|
123907
|
+
return undefined;
|
|
123908
|
+
var packageJson = ts.getPackageJsconLocationFromScope(scope);
|
|
123909
|
+
var result = packageJsons === null || packageJsons === void 0 ? void 0 : packageJsons.get(packageJson);
|
|
123910
|
+
if (result !== undefined)
|
|
123911
|
+
return result || undefined;
|
|
123912
|
+
if (resolutionHost.fileExists(packageJson)) {
|
|
123913
|
+
result = {
|
|
123914
|
+
info: ts.getPackageJsonInfo(ts.getDirectoryPath(packageJson),
|
|
123915
|
+
/*onlyRecordFailures*/ false, ts.getTemporaryModuleResolutionState(moduleResolutionCache.getPackageJsonInfoCache(), ((_a = resolutionHost.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(resolutionHost)) || resolutionHost, resolutionHost.getCompilationSettings())),
|
|
123916
|
+
affectingLocations: [packageJson],
|
|
123917
|
+
};
|
|
123918
|
+
}
|
|
123919
|
+
(packageJsons !== null && packageJsons !== void 0 ? packageJsons : (packageJsons = new ts.Map())).set(packageJson, result || false);
|
|
123920
|
+
return result;
|
|
123921
|
+
}
|
|
123922
|
+
};
|
|
123923
|
+
}
|
|
123924
|
+
function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
|
|
123925
|
+
var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
|
|
123926
|
+
var resolutionsInFile = perFileCache.get(path);
|
|
123927
|
+
var seenNamesInFile = ts.createModeAwareCache();
|
|
123928
|
+
perDirCache = toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, function (key) {
|
|
123929
|
+
// If keys dont match release existing resolutions
|
|
123930
|
+
if (resolutionsInFile && resolutionsInFile.key !== key) {
|
|
123931
|
+
resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
|
|
123932
|
+
resolutionsInFile = undefined;
|
|
123933
|
+
}
|
|
123934
|
+
}, function (r, name, mode, key) {
|
|
123935
|
+
seenNamesInFile.set(name, mode, true);
|
|
123936
|
+
var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
|
|
123937
|
+
if (existing && r !== existing)
|
|
123938
|
+
stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
|
|
123939
|
+
watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
|
|
123940
|
+
if (!resolutionsInFile)
|
|
123941
|
+
perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
|
|
123942
|
+
resolutionsInFile.cache.set(name, mode, r);
|
|
123943
|
+
}, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
|
|
123944
|
+
if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
|
|
123945
|
+
// Stop watching and remove the unused name
|
|
123946
|
+
resolutionsInFile.cache.forEach(function (resolution, name, mode) {
|
|
123947
|
+
if (!seenNamesInFile.has(name, mode)) {
|
|
123948
|
+
stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
123949
|
+
resolutionsInFile.cache.delete(name, mode);
|
|
123950
|
+
}
|
|
123951
|
+
});
|
|
123952
|
+
if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
|
|
123953
|
+
perFileCache.delete(path);
|
|
123954
|
+
}
|
|
123955
|
+
return perDirCache;
|
|
123956
|
+
}
|
|
123957
|
+
function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
|
|
123958
|
+
if (!modules && !typeRefs)
|
|
123959
|
+
return undefined;
|
|
123960
|
+
return {
|
|
123961
|
+
modules: {
|
|
123962
|
+
getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
|
|
123963
|
+
},
|
|
123964
|
+
typeRefs: {
|
|
123965
|
+
getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, /*moduleNameToDirectoryMap*/ undefined); }
|
|
123966
|
+
},
|
|
123967
|
+
clearRedirectsMap: function () {
|
|
123968
|
+
modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
|
|
123969
|
+
typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
|
|
123970
|
+
moduleNameToDirectoryMap.clearRedirectsMap();
|
|
123971
|
+
},
|
|
123972
|
+
};
|
|
123973
|
+
}
|
|
123974
|
+
function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
|
|
123975
|
+
var _a, _b, _c, _d;
|
|
123976
|
+
if (!perDirCache)
|
|
123977
|
+
return undefined;
|
|
123978
|
+
var result = ((_b = (_a = perDirCache.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(dirPath)) === null || _b === void 0 ? void 0 : _b.get(name, mode)) ||
|
|
123979
|
+
((_d = (_c = moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath));
|
|
123980
|
+
return result && !result.isInvalidated ? result : undefined;
|
|
123981
|
+
}
|
|
123982
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
|
|
123983
|
+
var _a;
|
|
122917
123984
|
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
122918
123985
|
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
|
|
122919
123986
|
if (!resolutionHost.getGlobalCache) {
|
|
@@ -122924,12 +123991,16 @@ var ts;
|
|
|
122924
123991
|
if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
|
|
122925
123992
|
// create different collection of failed lookup locations for second pass
|
|
122926
123993
|
// if it will fail and we've already found something during the first pass - we don't want to pollute its results
|
|
122927
|
-
var
|
|
123994
|
+
var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations, affectingLocations = _b.affectingLocations, resolutionDiagnostics = _b.resolutionDiagnostics;
|
|
122928
123995
|
if (resolvedModule) {
|
|
122929
123996
|
// Modify existing resolution so its saved in the directory cache as well
|
|
122930
123997
|
primaryResult.resolvedModule = resolvedModule;
|
|
122931
|
-
(
|
|
122932
|
-
|
|
123998
|
+
if (!compilerOptions.cacheResolutions)
|
|
123999
|
+
(_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
|
|
124000
|
+
else
|
|
124001
|
+
primaryResult.failedLookupLocations.length = 0;
|
|
124002
|
+
primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
|
|
124003
|
+
primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
|
|
122933
124004
|
return primaryResult;
|
|
122934
124005
|
}
|
|
122935
124006
|
}
|
|
@@ -122940,76 +124011,41 @@ var ts;
|
|
|
122940
124011
|
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
|
|
122941
124012
|
}
|
|
122942
124013
|
function resolveNamesWithLocalCache(_a) {
|
|
122943
|
-
var _b, _c, _d;
|
|
122944
|
-
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference,
|
|
124014
|
+
var _b, _c, _d, _e;
|
|
124015
|
+
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, perFileCache = _a.perFileCache, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, partialResolutionInfo = _a.partialResolutionInfo, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
|
|
122945
124016
|
var path = resolutionHost.toPath(containingFile);
|
|
122946
|
-
var resolutionsInFile =
|
|
122947
|
-
var
|
|
122948
|
-
var
|
|
122949
|
-
|
|
122950
|
-
|
|
122951
|
-
|
|
122952
|
-
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
|
124017
|
+
var resolutionsInFile = perFileCache.get(path);
|
|
124018
|
+
var compilerOptions = resolutionHost.getCompilationSettings();
|
|
124019
|
+
var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
|
|
124020
|
+
if (!resolutionsInFile || resolutionsInFile.key !== key) {
|
|
124021
|
+
resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
|
|
124022
|
+
perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
|
|
122953
124023
|
}
|
|
122954
124024
|
var resolvedModules = [];
|
|
122955
|
-
var compilerOptions = resolutionHost.getCompilationSettings();
|
|
122956
|
-
var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
|
|
122957
|
-
// All the resolutions in this file are invalidated if this file wasn't resolved using same redirect
|
|
122958
|
-
var program = resolutionHost.getCurrentProgram();
|
|
122959
|
-
var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
|
|
122960
|
-
var unmatchedRedirects = oldRedirect ?
|
|
122961
|
-
!redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
|
|
122962
|
-
!!redirectedReference;
|
|
122963
124025
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
122964
124026
|
var i = 0;
|
|
122965
|
-
for (var _i = 0,
|
|
122966
|
-
var entry =
|
|
122967
|
-
var name = ts.isString(entry) ? entry : entry.fileName
|
|
124027
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
124028
|
+
var entry = names_4[_i];
|
|
124029
|
+
var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
|
|
122968
124030
|
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
122969
124031
|
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
122970
124032
|
// import's syntax may override the file's default mode.
|
|
122971
124033
|
// Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
|
|
122972
124034
|
// a default file mode override if applicable.
|
|
122973
124035
|
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
|
|
122974
|
-
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
124036
|
+
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
|
|
122975
124037
|
i++;
|
|
122976
|
-
var resolution = resolutionsInFile.get(name, mode);
|
|
124038
|
+
var resolution = resolutionsInFile.cache.get(name, mode);
|
|
122977
124039
|
// Resolution is valid if it is present and not invalidated
|
|
122978
|
-
if (!seenNamesInFile.has(name, mode) &&
|
|
122979
|
-
unmatchedRedirects || !resolution || resolution.isInvalidated ||
|
|
122980
|
-
// If the name is unresolved import that was invalidated, recalculate
|
|
122981
|
-
(hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
|
|
124040
|
+
if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
|
|
122982
124041
|
var existingResolution = resolution;
|
|
122983
|
-
|
|
122984
|
-
if (
|
|
122985
|
-
|
|
122986
|
-
var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
|
|
122987
|
-
if (ts.isTraceEnabled(compilerOptions, host)) {
|
|
122988
|
-
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
122989
|
-
ts.trace(host, loader === resolveModuleName ?
|
|
122990
|
-
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
122991
|
-
resolved.packagetId ?
|
|
122992
|
-
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
|
|
122993
|
-
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
|
|
122994
|
-
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
|
|
122995
|
-
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
122996
|
-
resolved.packagetId ?
|
|
122997
|
-
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
|
|
122998
|
-
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
|
|
122999
|
-
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId));
|
|
123000
|
-
}
|
|
123001
|
-
}
|
|
123002
|
-
else {
|
|
123003
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
123004
|
-
perDirectoryResolution.set(name, mode, resolution);
|
|
123005
|
-
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
123006
|
-
resolutionHost.onDiscoveredSymlink();
|
|
123007
|
-
}
|
|
124042
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
124043
|
+
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
124044
|
+
resolutionHost.onDiscoveredSymlink();
|
|
123008
124045
|
}
|
|
123009
|
-
resolutionsInFile.set(name, mode, resolution);
|
|
123010
|
-
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
124046
|
+
resolutionsInFile.cache.set(name, mode, resolution);
|
|
123011
124047
|
if (existingResolution) {
|
|
123012
|
-
|
|
124048
|
+
stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
|
|
123013
124049
|
}
|
|
123014
124050
|
if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
|
|
123015
124051
|
filesWithChangedSetOfUnresolvedImports.push(path);
|
|
@@ -123023,28 +124059,34 @@ var ts;
|
|
|
123023
124059
|
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
123024
124060
|
ts.trace(host, loader === resolveModuleName ?
|
|
123025
124061
|
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
123026
|
-
resolved.
|
|
124062
|
+
resolved.packageId ?
|
|
123027
124063
|
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
|
|
123028
124064
|
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
|
|
123029
124065
|
ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
|
|
123030
124066
|
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
123031
|
-
resolved.
|
|
124067
|
+
resolved.packageId ?
|
|
123032
124068
|
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
|
|
123033
124069
|
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
|
|
123034
|
-
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.
|
|
124070
|
+
ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packageId) && ts.packageIdToString(resolved.packageId));
|
|
123035
124071
|
}
|
|
123036
124072
|
}
|
|
123037
124073
|
ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
|
|
123038
124074
|
seenNamesInFile.set(name, mode, true);
|
|
123039
|
-
resolvedModules.push(
|
|
124075
|
+
resolvedModules.push(resolution);
|
|
123040
124076
|
}
|
|
123041
|
-
|
|
123042
|
-
|
|
123043
|
-
|
|
123044
|
-
stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
123045
|
-
resolutionsInFile.delete(name, mode);
|
|
123046
|
-
}
|
|
124077
|
+
(_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
|
|
124078
|
+
var name = _a.name, mode = _a.mode;
|
|
124079
|
+
return seenNamesInFile.set(name, mode, true);
|
|
123047
124080
|
});
|
|
124081
|
+
if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
|
|
124082
|
+
// Stop watching and remove the unused name
|
|
124083
|
+
resolutionsInFile.cache.forEach(function (resolution, name, mode) {
|
|
124084
|
+
if (!seenNamesInFile.has(name, mode)) {
|
|
124085
|
+
stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
124086
|
+
resolutionsInFile.cache.delete(name, mode);
|
|
124087
|
+
}
|
|
124088
|
+
});
|
|
124089
|
+
}
|
|
123048
124090
|
return resolvedModules;
|
|
123049
124091
|
function resolutionIsEqualTo(oldResolution, newResolution) {
|
|
123050
124092
|
if (oldResolution === newResolution) {
|
|
@@ -123064,40 +124106,31 @@ var ts;
|
|
|
123064
124106
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
123065
124107
|
}
|
|
123066
124108
|
}
|
|
123067
|
-
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
124109
|
+
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
|
|
123068
124110
|
return resolveNamesWithLocalCache({
|
|
123069
124111
|
names: typeDirectiveNames,
|
|
123070
124112
|
containingFile: containingFile,
|
|
123071
124113
|
redirectedReference: redirectedReference,
|
|
123072
|
-
|
|
123073
|
-
perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
|
|
124114
|
+
perFileCache: resolvedTypeReferenceDirectives,
|
|
123074
124115
|
loader: resolveTypeReferenceDirective,
|
|
123075
|
-
getResolutionWithResolvedFileName:
|
|
123076
|
-
|
|
123077
|
-
|
|
124116
|
+
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveOfResolution,
|
|
124117
|
+
containingSourceFileMode: containingFileMode,
|
|
124118
|
+
partialResolutionInfo: partialResolutionInfo,
|
|
123078
124119
|
});
|
|
123079
124120
|
}
|
|
123080
|
-
function resolveModuleNames(moduleNames, containingFile,
|
|
124121
|
+
function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
|
|
123081
124122
|
return resolveNamesWithLocalCache({
|
|
123082
124123
|
names: moduleNames,
|
|
123083
124124
|
containingFile: containingFile,
|
|
123084
124125
|
redirectedReference: redirectedReference,
|
|
123085
|
-
|
|
123086
|
-
perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
|
|
124126
|
+
perFileCache: resolvedModuleNames,
|
|
123087
124127
|
loader: resolveModuleName,
|
|
123088
|
-
getResolutionWithResolvedFileName:
|
|
123089
|
-
|
|
123090
|
-
reusedNames: reusedNames,
|
|
124128
|
+
getResolutionWithResolvedFileName: getResolvedModuleOfResolution,
|
|
124129
|
+
partialResolutionInfo: partialResolutionInfo,
|
|
123091
124130
|
logChanges: logChangesWhenResolvingModule,
|
|
123092
124131
|
containingSourceFile: containingSourceFile,
|
|
123093
124132
|
});
|
|
123094
124133
|
}
|
|
123095
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
|
|
123096
|
-
var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
|
|
123097
|
-
if (!cache)
|
|
123098
|
-
return undefined;
|
|
123099
|
-
return cache.get(moduleName, resolutionMode);
|
|
123100
|
-
}
|
|
123101
124134
|
function isNodeModulesAtTypesDirectory(dirPath) {
|
|
123102
124135
|
return ts.endsWith(dirPath, "/node_modules/@types");
|
|
123103
124136
|
}
|
|
@@ -123157,37 +124190,42 @@ var ts;
|
|
|
123157
124190
|
function isPathWithDefaultFailedLookupExtension(path) {
|
|
123158
124191
|
return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
123159
124192
|
}
|
|
123160
|
-
function
|
|
123161
|
-
if (resolution.
|
|
123162
|
-
resolution.
|
|
123163
|
-
|
|
124193
|
+
function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
|
|
124194
|
+
if (resolution.files) {
|
|
124195
|
+
resolution.files.add(filePath);
|
|
124196
|
+
if (resolution.watchedFailed !== false)
|
|
124197
|
+
watchFailedLookupLocationOfResolution(resolution);
|
|
124198
|
+
watchAffectingLocationsOfResolution(resolution);
|
|
124199
|
+
return;
|
|
124200
|
+
}
|
|
124201
|
+
resolution.files = new ts.Set();
|
|
124202
|
+
resolution.files.add(filePath);
|
|
124203
|
+
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
124204
|
+
if (resolved && resolved.resolvedFileName) {
|
|
124205
|
+
resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
|
|
124206
|
+
}
|
|
124207
|
+
if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
|
|
124208
|
+
watchFailedLookupLocationOfResolution(resolution);
|
|
124209
|
+
watchAffectingLocationsOfResolution(resolution);
|
|
123164
124210
|
}
|
|
123165
124211
|
else {
|
|
123166
|
-
resolution.
|
|
123167
|
-
|
|
123168
|
-
if (ts.isExternalModuleNameRelative(name)) {
|
|
123169
|
-
watchFailedLookupLocationOfResolution(resolution);
|
|
123170
|
-
}
|
|
123171
|
-
else {
|
|
123172
|
-
nonRelativeExternalModuleResolutions.add(name, resolution);
|
|
123173
|
-
}
|
|
123174
|
-
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
123175
|
-
if (resolved && resolved.resolvedFileName) {
|
|
123176
|
-
resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
|
|
123177
|
-
}
|
|
124212
|
+
resolution.watchedFailed = false;
|
|
124213
|
+
watchAffectingLocationsOfResolution(resolution);
|
|
123178
124214
|
}
|
|
123179
|
-
(resolution.files || (resolution.files = [])).push(filePath);
|
|
123180
124215
|
}
|
|
123181
124216
|
function watchFailedLookupLocationOfResolution(resolution) {
|
|
123182
|
-
|
|
123183
|
-
|
|
123184
|
-
if (!failedLookupLocations.length && !affectingLocations.length)
|
|
124217
|
+
var failedLookupLocations = resolution.failedLookupLocations;
|
|
124218
|
+
if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
|
|
123185
124219
|
return;
|
|
123186
|
-
if (
|
|
124220
|
+
if (!resolution.watchedFailed) {
|
|
123187
124221
|
resolutionsWithFailedLookups.push(resolution);
|
|
123188
|
-
|
|
123189
|
-
|
|
123190
|
-
|
|
124222
|
+
// Remove resolution from only watching affected locations
|
|
124223
|
+
if (resolution.watchedAffected)
|
|
124224
|
+
ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
|
|
124225
|
+
}
|
|
124226
|
+
var setAtRoot = !!resolution.setAtRoot;
|
|
124227
|
+
for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
|
|
124228
|
+
var failedLookupLocation = failedLookupLocations[i];
|
|
123191
124229
|
var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
123192
124230
|
var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
|
|
123193
124231
|
if (toWatch) {
|
|
@@ -123207,24 +124245,24 @@ var ts;
|
|
|
123207
124245
|
}
|
|
123208
124246
|
}
|
|
123209
124247
|
}
|
|
123210
|
-
if (setAtRoot) {
|
|
124248
|
+
if (setAtRoot && !resolution.setAtRoot) {
|
|
123211
124249
|
// This is always non recursive
|
|
123212
|
-
setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true);
|
|
124250
|
+
setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true);
|
|
123213
124251
|
}
|
|
123214
|
-
|
|
124252
|
+
resolution.setAtRoot = setAtRoot;
|
|
124253
|
+
resolution.watchedFailed = failedLookupLocations.length;
|
|
123215
124254
|
}
|
|
123216
|
-
function watchAffectingLocationsOfResolution(resolution
|
|
123217
|
-
ts.Debug.assert(!!resolution.refCount);
|
|
124255
|
+
function watchAffectingLocationsOfResolution(resolution) {
|
|
123218
124256
|
var affectingLocations = resolution.affectingLocations;
|
|
123219
|
-
if (!affectingLocations.length)
|
|
124257
|
+
if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
|
|
123220
124258
|
return;
|
|
123221
|
-
if (
|
|
124259
|
+
if (!resolution.watchedFailed && !resolution.watchedAffected)
|
|
123222
124260
|
resolutionsWithOnlyAffectingLocations.push(resolution);
|
|
123223
124261
|
// Watch package json
|
|
123224
|
-
for (var
|
|
123225
|
-
|
|
123226
|
-
createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
|
|
124262
|
+
for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
|
|
124263
|
+
createFileWatcherOfAffectingLocation(affectingLocations[i], /*forResolution*/ true);
|
|
123227
124264
|
}
|
|
124265
|
+
resolution.watchedAffected = affectingLocations.length;
|
|
123228
124266
|
}
|
|
123229
124267
|
function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
|
|
123230
124268
|
var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
@@ -123284,15 +124322,6 @@ var ts;
|
|
|
123284
124322
|
paths.add(affectingLocation);
|
|
123285
124323
|
}
|
|
123286
124324
|
}
|
|
123287
|
-
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
|
|
123288
|
-
var program = resolutionHost.getCurrentProgram();
|
|
123289
|
-
if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
|
|
123290
|
-
resolutions.forEach(watchFailedLookupLocationOfResolution);
|
|
123291
|
-
}
|
|
123292
|
-
else {
|
|
123293
|
-
resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
|
|
123294
|
-
}
|
|
123295
|
-
}
|
|
123296
124325
|
function setDirectoryWatcher(dir, dirPath, nonRecursive) {
|
|
123297
124326
|
var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
|
|
123298
124327
|
if (dirWatcher) {
|
|
@@ -123303,21 +124332,28 @@ var ts;
|
|
|
123303
124332
|
directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
|
|
123304
124333
|
}
|
|
123305
124334
|
}
|
|
123306
|
-
function
|
|
123307
|
-
|
|
123308
|
-
resolution.
|
|
123309
|
-
if (resolution.
|
|
124335
|
+
function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
|
|
124336
|
+
var _a, _b;
|
|
124337
|
+
(_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
|
|
124338
|
+
if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
|
|
124339
|
+
(resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
|
|
124340
|
+
}
|
|
124341
|
+
function closeWatchersOfResolution(_a) {
|
|
124342
|
+
var _b;
|
|
124343
|
+
var resolution = _a.resolution, getResolved = _a.getResolved;
|
|
124344
|
+
// If some files are using this resolution or we have already closed all watchers ignore
|
|
124345
|
+
if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
|
|
123310
124346
|
return;
|
|
123311
|
-
|
|
123312
|
-
var resolved =
|
|
124347
|
+
resolution.files = undefined;
|
|
124348
|
+
var resolved = getResolved(resolution);
|
|
123313
124349
|
if (resolved && resolved.resolvedFileName) {
|
|
123314
124350
|
resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
|
|
123315
124351
|
}
|
|
123316
|
-
|
|
123317
|
-
|
|
124352
|
+
if (resolution.watchedFailed) {
|
|
124353
|
+
ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
|
|
123318
124354
|
var removeAtRoot = false;
|
|
123319
|
-
for (var
|
|
123320
|
-
var failedLookupLocation =
|
|
124355
|
+
for (var i = 0; i < resolution.watchedFailed; i++) {
|
|
124356
|
+
var failedLookupLocation = resolution.failedLookupLocations[i];
|
|
123321
124357
|
var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
123322
124358
|
var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
|
|
123323
124359
|
if (toWatch) {
|
|
@@ -123340,23 +124376,28 @@ var ts;
|
|
|
123340
124376
|
}
|
|
123341
124377
|
}
|
|
123342
124378
|
}
|
|
124379
|
+
ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
|
|
123343
124380
|
if (removeAtRoot) {
|
|
123344
124381
|
removeDirectoryWatcher(rootPath);
|
|
123345
124382
|
}
|
|
123346
124383
|
}
|
|
123347
|
-
else if (
|
|
124384
|
+
else if (resolution.watchedAffected) {
|
|
123348
124385
|
ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
|
|
123349
124386
|
}
|
|
123350
|
-
|
|
123351
|
-
var
|
|
123352
|
-
|
|
123353
|
-
|
|
124387
|
+
if (resolution.watchedAffected) {
|
|
124388
|
+
for (var i = 0; i < resolution.watchedAffected; i++) {
|
|
124389
|
+
var watcher = fileWatchesOfAffectingLocations.get(resolution.affectingLocations[i]);
|
|
124390
|
+
watcher.resolutions--;
|
|
124391
|
+
}
|
|
123354
124392
|
}
|
|
123355
124393
|
}
|
|
123356
124394
|
function removeDirectoryWatcher(dirPath) {
|
|
123357
124395
|
var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
|
|
123358
|
-
// Do not close the watcher yet since it might be needed by other failed lookup locations.
|
|
123359
124396
|
dirWatcher.refCount--;
|
|
124397
|
+
if (dirWatcher.refCount === 0) {
|
|
124398
|
+
directoryWatchesOfFailedLookups.delete(dirPath);
|
|
124399
|
+
dirWatcher.watcher.close();
|
|
124400
|
+
}
|
|
123360
124401
|
}
|
|
123361
124402
|
function createDirectoryWatcher(directory, dirPath, nonRecursive) {
|
|
123362
124403
|
return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
|
|
@@ -123372,28 +124413,16 @@ var ts;
|
|
|
123372
124413
|
// Deleted file, stop watching failed lookups for all the resolutions in the file
|
|
123373
124414
|
var resolutions = cache.get(filePath);
|
|
123374
124415
|
if (resolutions) {
|
|
123375
|
-
resolutions.forEach(function (resolution) { return
|
|
124416
|
+
resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
|
|
123376
124417
|
cache.delete(filePath);
|
|
123377
124418
|
}
|
|
123378
124419
|
}
|
|
123379
|
-
function removeResolutionsFromProjectReferenceRedirects(filePath) {
|
|
123380
|
-
if (!ts.fileExtensionIs(filePath, ".json" /* Json */))
|
|
123381
|
-
return;
|
|
123382
|
-
var program = resolutionHost.getCurrentProgram();
|
|
123383
|
-
if (!program)
|
|
123384
|
-
return;
|
|
123385
|
-
// If this file is input file for the referenced project, get it
|
|
123386
|
-
var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
|
|
123387
|
-
if (!resolvedProjectReference)
|
|
123388
|
-
return;
|
|
123389
|
-
// filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution
|
|
123390
|
-
resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
|
|
123391
|
-
}
|
|
123392
124420
|
function removeResolutionsOfFile(filePath) {
|
|
123393
|
-
removeResolutionsOfFileFromCache(resolvedModuleNames, filePath,
|
|
123394
|
-
removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath,
|
|
124421
|
+
removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleOfResolution);
|
|
124422
|
+
removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveOfResolution);
|
|
123395
124423
|
}
|
|
123396
124424
|
function invalidateResolutions(resolutions, canInvalidate) {
|
|
124425
|
+
var _a;
|
|
123397
124426
|
if (!resolutions)
|
|
123398
124427
|
return false;
|
|
123399
124428
|
var invalidated = false;
|
|
@@ -123402,17 +124431,15 @@ var ts;
|
|
|
123402
124431
|
if (resolution.isInvalidated || !canInvalidate(resolution))
|
|
123403
124432
|
continue;
|
|
123404
124433
|
resolution.isInvalidated = invalidated = true;
|
|
123405
|
-
|
|
123406
|
-
var containingFilePath = _b[_a];
|
|
124434
|
+
(_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
|
|
123407
124435
|
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
|
|
123408
124436
|
// When its a file with inferred types resolution, invalidate type reference directive resolution
|
|
123409
124437
|
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
|
|
123410
|
-
}
|
|
124438
|
+
});
|
|
123411
124439
|
}
|
|
123412
124440
|
return invalidated;
|
|
123413
124441
|
}
|
|
123414
124442
|
function invalidateResolutionOfFile(filePath) {
|
|
123415
|
-
removeResolutionsOfFile(filePath);
|
|
123416
124443
|
// Resolution is invalidated if the resulting file name is same as the deleted file path
|
|
123417
124444
|
var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
|
|
123418
124445
|
if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
|
|
@@ -123422,8 +124449,28 @@ var ts;
|
|
|
123422
124449
|
}
|
|
123423
124450
|
}
|
|
123424
124451
|
function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
|
|
123425
|
-
|
|
123426
|
-
|
|
124452
|
+
filesMap.forEach(function (_a, filePath) {
|
|
124453
|
+
var imports = _a.imports;
|
|
124454
|
+
if (!imports.length)
|
|
124455
|
+
return;
|
|
124456
|
+
var resolvedModules = resolvedModuleNames.get(filePath);
|
|
124457
|
+
var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
|
|
124458
|
+
if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
|
|
124459
|
+
return;
|
|
124460
|
+
imports.forEach(function (_a) {
|
|
124461
|
+
var name = _a.name, mode = _a.mode;
|
|
124462
|
+
var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
|
|
124463
|
+
if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
|
|
124464
|
+
resolvedModule.isInvalidated = true;
|
|
124465
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
|
|
124466
|
+
}
|
|
124467
|
+
var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
|
|
124468
|
+
if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
|
|
124469
|
+
resolvedTypeRef.isInvalidated = true;
|
|
124470
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
|
|
124471
|
+
}
|
|
124472
|
+
});
|
|
124473
|
+
});
|
|
123427
124474
|
}
|
|
123428
124475
|
function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
|
|
123429
124476
|
if (isCreatingWatchedDirectory) {
|
|
@@ -123474,12 +124521,17 @@ var ts;
|
|
|
123474
124521
|
var _a;
|
|
123475
124522
|
var invalidated = false;
|
|
123476
124523
|
if (affectingPathChecksForFile) {
|
|
123477
|
-
|
|
123478
|
-
|
|
123479
|
-
|
|
124524
|
+
for (var _i = 0, watchedPackageJsonScopes_1 = watchedPackageJsonScopes; _i < watchedPackageJsonScopes_1.length; _i++) {
|
|
124525
|
+
var scope = watchedPackageJsonScopes_1[_i];
|
|
124526
|
+
if (scope.isInvalidated)
|
|
124527
|
+
continue;
|
|
124528
|
+
if (ts.some(scope.failedLookupLocations, function (location) { return affectingPathChecksForFile.has(location); }) ||
|
|
124529
|
+
ts.some(scope.affectingLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
|
|
124530
|
+
scope.isInvalidated = true;
|
|
123480
124531
|
invalidated = true;
|
|
124532
|
+
(_a = scope.files) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(path); });
|
|
123481
124533
|
}
|
|
123482
|
-
}
|
|
124534
|
+
}
|
|
123483
124535
|
affectingPathChecksForFile = undefined;
|
|
123484
124536
|
}
|
|
123485
124537
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
|
|
@@ -123510,7 +124562,8 @@ var ts;
|
|
|
123510
124562
|
ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
|
|
123511
124563
|
}
|
|
123512
124564
|
function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
|
|
123513
|
-
|
|
124565
|
+
var _a;
|
|
124566
|
+
return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) { return affectingPathChecks.has(location); }));
|
|
123514
124567
|
}
|
|
123515
124568
|
function closeTypeRootsWatch() {
|
|
123516
124569
|
ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
|
|
@@ -123899,9 +124952,9 @@ var ts;
|
|
|
123899
124952
|
if (!preferSymlinks) {
|
|
123900
124953
|
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
|
123901
124954
|
// so we only need to remove them from the realpath filenames.
|
|
123902
|
-
var
|
|
123903
|
-
if (
|
|
123904
|
-
return
|
|
124955
|
+
var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
|
|
124956
|
+
if (result_17)
|
|
124957
|
+
return result_17;
|
|
123905
124958
|
}
|
|
123906
124959
|
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
|
|
123907
124960
|
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
|
|
@@ -123921,10 +124974,10 @@ var ts;
|
|
|
123921
124974
|
for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
|
|
123922
124975
|
var symlinkDirectory = symlinkDirectories_1[_i];
|
|
123923
124976
|
var option = ts.resolvePath(symlinkDirectory, relative);
|
|
123924
|
-
var
|
|
124977
|
+
var result_18 = cb(option, target === referenceRedirect);
|
|
123925
124978
|
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
|
123926
|
-
if (
|
|
123927
|
-
return
|
|
124979
|
+
if (result_18)
|
|
124980
|
+
return result_18;
|
|
123928
124981
|
}
|
|
123929
124982
|
});
|
|
123930
124983
|
});
|
|
@@ -123990,9 +125043,9 @@ var ts;
|
|
|
123990
125043
|
};
|
|
123991
125044
|
var out_directory_1;
|
|
123992
125045
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
123993
|
-
var
|
|
125046
|
+
var state_12 = _loop_35(directory);
|
|
123994
125047
|
directory = out_directory_1;
|
|
123995
|
-
if (
|
|
125048
|
+
if (state_12 === "break")
|
|
123996
125049
|
break;
|
|
123997
125050
|
}
|
|
123998
125051
|
if (allFileNames.size) {
|
|
@@ -124128,9 +125181,9 @@ var ts;
|
|
|
124128
125181
|
};
|
|
124129
125182
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124130
125183
|
var patternText_1 = _a[_i];
|
|
124131
|
-
var
|
|
124132
|
-
if (typeof
|
|
124133
|
-
return
|
|
125184
|
+
var state_13 = _loop_36(patternText_1);
|
|
125185
|
+
if (typeof state_13 === "object")
|
|
125186
|
+
return state_13.value;
|
|
124134
125187
|
}
|
|
124135
125188
|
}
|
|
124136
125189
|
function validateEnding(_a) {
|
|
@@ -124635,7 +125688,7 @@ var ts;
|
|
|
124635
125688
|
}
|
|
124636
125689
|
ts.explainFiles = explainFiles;
|
|
124637
125690
|
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
124638
|
-
var _a;
|
|
125691
|
+
var _a, _b;
|
|
124639
125692
|
var result;
|
|
124640
125693
|
if (file.path !== file.resolvedPath) {
|
|
124641
125694
|
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
@@ -124648,19 +125701,19 @@ var ts;
|
|
|
124648
125701
|
if (ts.isExternalOrCommonJsModule(file)) {
|
|
124649
125702
|
switch (file.impliedNodeFormat) {
|
|
124650
125703
|
case ts.ModuleKind.ESNext:
|
|
124651
|
-
if (file.packageJsonScope) {
|
|
125704
|
+
if ((_a = file.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
|
|
124652
125705
|
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124653
|
-
/*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.
|
|
125706
|
+
/*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
|
|
124654
125707
|
}
|
|
124655
125708
|
break;
|
|
124656
125709
|
case ts.ModuleKind.CommonJS:
|
|
124657
|
-
if (file.packageJsonScope) {
|
|
125710
|
+
if ((_b = file.packageJsonScope) === null || _b === void 0 ? void 0 : _b.info) {
|
|
124658
125711
|
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124659
|
-
/*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
|
|
125712
|
+
/*details*/ undefined, file.packageJsonScope.info.packageJsonContent.type ?
|
|
124660
125713
|
ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
|
|
124661
|
-
ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.
|
|
125714
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
|
|
124662
125715
|
}
|
|
124663
|
-
else if (
|
|
125716
|
+
else if (file.packageJsonScope) {
|
|
124664
125717
|
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124665
125718
|
/*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
|
|
124666
125719
|
}
|
|
@@ -125067,7 +126120,8 @@ var ts;
|
|
|
125067
126120
|
})(ts || (ts = {}));
|
|
125068
126121
|
var ts;
|
|
125069
126122
|
(function (ts) {
|
|
125070
|
-
|
|
126123
|
+
/*@internal*/
|
|
126124
|
+
function readBuildInfoForProgram(compilerOptions, host) {
|
|
125071
126125
|
var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
|
|
125072
126126
|
if (!buildInfoPath)
|
|
125073
126127
|
return undefined;
|
|
@@ -125088,7 +126142,12 @@ var ts;
|
|
|
125088
126142
|
return undefined;
|
|
125089
126143
|
if (!buildInfo.program)
|
|
125090
126144
|
return undefined;
|
|
125091
|
-
return
|
|
126145
|
+
return { buildInfo: buildInfo, buildInfoPath: buildInfoPath };
|
|
126146
|
+
}
|
|
126147
|
+
ts.readBuildInfoForProgram = readBuildInfoForProgram;
|
|
126148
|
+
function readBuilderProgram(compilerOptions, host) {
|
|
126149
|
+
var result = readBuildInfoForProgram(compilerOptions, host);
|
|
126150
|
+
return result && ts.createBuilderProgramUsingProgramBuildInfo(result.buildInfo.program, result.buildInfoPath, host, compilerOptions.configFilePath);
|
|
125092
126151
|
}
|
|
125093
126152
|
ts.readBuilderProgram = readBuilderProgram;
|
|
125094
126153
|
function createIncrementalCompilerHost(options, system) {
|
|
@@ -125227,7 +126286,7 @@ var ts;
|
|
|
125227
126286
|
}
|
|
125228
126287
|
return host.resolveModuleNames.apply(host, args);
|
|
125229
126288
|
}) :
|
|
125230
|
-
(function (moduleNames, containingFile,
|
|
126289
|
+
(function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, sourceFile, partialResolutionInfo) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, sourceFile, partialResolutionInfo); });
|
|
125231
126290
|
compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
|
|
125232
126291
|
(function () {
|
|
125233
126292
|
var args = [];
|
|
@@ -125236,10 +126295,13 @@ var ts;
|
|
|
125236
126295
|
}
|
|
125237
126296
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
125238
126297
|
}) :
|
|
125239
|
-
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
126298
|
+
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo); });
|
|
125240
126299
|
compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
|
|
125241
126300
|
ts.maybeBind(host, host.getModuleResolutionCache) :
|
|
125242
126301
|
(function () { return resolutionCache.getModuleResolutionCache(); });
|
|
126302
|
+
compilerHost.getTypeReferenceDirectiveResolutionCache = host.resolveTypeReferenceDirectives ?
|
|
126303
|
+
ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache) :
|
|
126304
|
+
(function () { return resolutionCache.getTypeReferenceDirectiveResolutionCache(); });
|
|
125243
126305
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
125244
126306
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
125245
126307
|
synchronizeProgram();
|
|
@@ -125308,7 +126370,8 @@ var ts;
|
|
|
125308
126370
|
}
|
|
125309
126371
|
// All resolutions are invalid if user provided resolutions
|
|
125310
126372
|
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
|
|
125311
|
-
|
|
126373
|
+
var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
|
|
126374
|
+
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
125312
126375
|
if (hasChangedConfigFileParsingErrors) {
|
|
125313
126376
|
if (reportFileChangeDetectedOnCreateProgram) {
|
|
125314
126377
|
reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
@@ -125327,6 +126390,11 @@ var ts;
|
|
|
125327
126390
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
125328
126391
|
host.afterProgramCreate(builderProgram);
|
|
125329
126392
|
}
|
|
126393
|
+
compilerHost.readFile = originalReadFile;
|
|
126394
|
+
compilerHost.fileExists = originalFileExists;
|
|
126395
|
+
compilerHost.directoryExists = originalDirectoryExists;
|
|
126396
|
+
compilerHost.createDirectory = originalCreateDirectory;
|
|
126397
|
+
compilerHost.writeFile = originalWriteFile;
|
|
125330
126398
|
return builderProgram;
|
|
125331
126399
|
}
|
|
125332
126400
|
function createNewProgram(hasInvalidatedResolution) {
|
|
@@ -125336,7 +126404,6 @@ var ts;
|
|
|
125336
126404
|
writeLog(" options: " + JSON.stringify(compilerOptions));
|
|
125337
126405
|
if (projectReferences)
|
|
125338
126406
|
writeLog(" projectReferences: " + JSON.stringify(projectReferences));
|
|
125339
|
-
var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
|
|
125340
126407
|
hasChangedCompilerOptions = false;
|
|
125341
126408
|
hasChangedConfigFileParsingErrors = false;
|
|
125342
126409
|
resolutionCache.startCachingPerDirectoryResolution();
|
|
@@ -125347,9 +126414,6 @@ var ts;
|
|
|
125347
126414
|
resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
|
|
125348
126415
|
// Update watches
|
|
125349
126416
|
ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
|
|
125350
|
-
if (needsUpdateInTypeRootWatch) {
|
|
125351
|
-
resolutionCache.updateTypeRootsWatch();
|
|
125352
|
-
}
|
|
125353
126417
|
if (missingFilePathsRequestedForRelease) {
|
|
125354
126418
|
// These are the paths that program creater told us as not in use any more but were missing on the disk.
|
|
125355
126419
|
// We didnt remove the entry for them from sourceFiles cache so that we dont have to do File IO,
|
|
@@ -125446,7 +126510,7 @@ var ts;
|
|
|
125446
126510
|
var hostSourceFile = sourceFilesCache.get(path);
|
|
125447
126511
|
return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
|
|
125448
126512
|
}
|
|
125449
|
-
function onReleaseOldSourceFile(oldSourceFile
|
|
126513
|
+
function onReleaseOldSourceFile(oldSourceFile) {
|
|
125450
126514
|
var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
|
|
125451
126515
|
// If this is the source file thats in the cache and new program doesnt need it,
|
|
125452
126516
|
// remove the cached entry.
|
|
@@ -125462,9 +126526,6 @@ var ts;
|
|
|
125462
126526
|
hostSourceFileInfo.fileWatcher.close();
|
|
125463
126527
|
}
|
|
125464
126528
|
sourceFilesCache.delete(oldSourceFile.resolvedPath);
|
|
125465
|
-
if (!hasSourceFileByPath) {
|
|
125466
|
-
resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
|
|
125467
|
-
}
|
|
125468
126529
|
}
|
|
125469
126530
|
}
|
|
125470
126531
|
}
|
|
@@ -125721,7 +126782,6 @@ var ts;
|
|
|
125721
126782
|
var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
|
|
125722
126783
|
if (config)
|
|
125723
126784
|
config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
|
|
125724
|
-
resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
|
|
125725
126785
|
}
|
|
125726
126786
|
scheduleProgramUpdate();
|
|
125727
126787
|
});
|
|
@@ -125735,7 +126795,6 @@ var ts;
|
|
|
125735
126795
|
var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
|
|
125736
126796
|
if (config)
|
|
125737
126797
|
config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
|
|
125738
|
-
resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
|
|
125739
126798
|
scheduleProgramUpdate();
|
|
125740
126799
|
}, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
|
|
125741
126800
|
// Watch Wild card
|
|
@@ -125942,20 +127001,22 @@ var ts;
|
|
|
125942
127001
|
compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
|
|
125943
127002
|
compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
|
|
125944
127003
|
compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
|
|
127004
|
+
compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
|
|
125945
127005
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
125946
127006
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
125947
127007
|
if (!compilerHost.resolveModuleNames) {
|
|
125948
|
-
var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode)
|
|
125949
|
-
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
|
|
125950
|
-
return ts.loadWithModeAwareCache(
|
|
127008
|
+
var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
|
|
127009
|
+
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
|
|
127010
|
+
return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
|
|
125951
127011
|
};
|
|
125952
127012
|
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
125953
127013
|
}
|
|
125954
127014
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
125955
|
-
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode)
|
|
127015
|
+
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
|
|
125956
127016
|
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
125957
|
-
return ts.loadWithTypeDirectiveCache(
|
|
127017
|
+
return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
|
|
125958
127018
|
};
|
|
127019
|
+
compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
|
|
125959
127020
|
}
|
|
125960
127021
|
compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
|
|
125961
127022
|
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
|
|
@@ -126943,7 +128004,7 @@ var ts;
|
|
|
126943
128004
|
if (buildInfoTime && buildInfoTime < inputTime) {
|
|
126944
128005
|
var version_3 = void 0;
|
|
126945
128006
|
var currentVersion = void 0;
|
|
126946
|
-
if (buildInfoProgram) {
|
|
128007
|
+
if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
|
|
126947
128008
|
// Read files and see if they are same, read is anyways cached
|
|
126948
128009
|
if (!buildInfoVersionMap)
|
|
126949
128010
|
buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
|