Skip to content

Commit 457cbba

Browse files
Update LKG.
1 parent 15649f2 commit 457cbba

File tree

6 files changed

+162
-138
lines changed

6 files changed

+162
-138
lines changed

lib/tsc.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
6060
var ts;
6161
(function (ts) {
6262
ts.versionMajorMinor = "3.1";
63-
ts.version = ts.versionMajorMinor + ".5";
63+
ts.version = ts.versionMajorMinor + ".6";
6464
})(ts || (ts = {}));
6565
(function (ts) {
6666
ts.emptyArray = [];
@@ -68677,7 +68677,7 @@ var ts;
6867768677
var diagnosticsProducingTypeChecker;
6867868678
var noDiagnosticsTypeChecker;
6867968679
var classifiableNames;
68680-
var modifiedFilePaths;
68680+
var ambientModuleNameToUnmodifiedFileName = ts.createMap();
6868168681
var cachedSemanticDiagnosticsForFile = {};
6868268682
var cachedDeclarationDiagnosticsForFile = {};
6868368683
var resolvedTypeReferenceDirectives = ts.createMap();
@@ -68884,11 +68884,11 @@ var ts;
6888468884
}
6888568885
return classifiableNames;
6888668886
}
68887-
function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) {
68887+
function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) {
6888868888
if (structuralIsReused === 0 && !file.ambientModuleNames.length) {
6888968889
return resolveModuleNamesWorker(moduleNames, containingFile);
6889068890
}
68891-
var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile);
68891+
var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile);
6889268892
if (oldSourceFile !== file && file.resolvedModules) {
6889368893
var result_5 = [];
6889468894
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
@@ -68923,7 +68923,7 @@ var ts;
6892368923
}
6892468924
}
6892568925
else {
68926-
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState);
68926+
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
6892768927
}
6892868928
if (resolvesToAmbientModuleInNonModifiedFile) {
6892968929
(result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
@@ -68953,21 +68953,18 @@ var ts;
6895368953
}
6895468954
ts.Debug.assert(j === resolutions.length);
6895568955
return result;
68956-
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) {
68957-
if (!oldProgramState.program) {
68958-
return false;
68959-
}
68960-
var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName);
68961-
var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName);
68956+
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
68957+
var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
68958+
var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
6896268959
if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) {
6896368960
return false;
6896468961
}
68965-
var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); });
68966-
if (!firstUnmodifiedFile) {
68962+
var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
68963+
if (!unmodifiedFile) {
6896768964
return false;
6896868965
}
6896968966
if (ts.isTraceEnabled(options, host)) {
68970-
ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName);
68967+
ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
6897168968
}
6897268969
return true;
6897368970
}
@@ -69096,14 +69093,22 @@ var ts;
6909669093
if (oldProgram.structureIsReused !== 2) {
6909769094
return oldProgram.structureIsReused;
6909869095
}
69099-
modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; });
69100-
for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) {
69101-
var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile;
69096+
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
69097+
for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
69098+
var oldFile = oldSourceFiles_3[_a];
69099+
if (!ts.contains(modifiedFiles, oldFile)) {
69100+
for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
69101+
var moduleName = _c[_b];
69102+
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
69103+
}
69104+
}
69105+
}
69106+
for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
69107+
var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
6910269108
var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory);
6910369109
if (resolveModuleNamesWorker) {
6910469110
var moduleNames = getModuleNames(newSourceFile);
69105-
var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths };
69106-
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState);
69111+
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile);
6910769112
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
6910869113
if (resolutionsChanged) {
6910969114
oldProgram.structureIsReused = 1;
@@ -69141,8 +69146,8 @@ var ts;
6914169146
}
6914269147
files = newSourceFiles;
6914369148
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
69144-
for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) {
69145-
var modifiedFile = modifiedSourceFiles_2[_c];
69149+
for (var _f = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _f < modifiedSourceFiles_2.length; _f++) {
69150+
var modifiedFile = modifiedSourceFiles_2[_f];
6914669151
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
6914769152
}
6914869153
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
@@ -69944,8 +69949,7 @@ var ts;
6994469949
collectExternalModuleReferences(file);
6994569950
if (file.imports.length || file.moduleAugmentations.length) {
6994669951
var moduleNames = getModuleNames(file);
69947-
var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths };
69948-
var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState);
69952+
var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file);
6994969953
ts.Debug.assert(resolutions.length === moduleNames.length);
6995069954
for (var i = 0; i < moduleNames.length; i++) {
6995169955
var resolution = resolutions[i];

lib/tsserver.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var ts;
8888
// If changing the text in this section, be sure to test `configureNightly` too.
8989
ts.versionMajorMinor = "3.1";
9090
/** The version of the TypeScript compiler release */
91-
ts.version = ts.versionMajorMinor + ".5";
91+
ts.version = ts.versionMajorMinor + ".6";
9292
})(ts || (ts = {}));
9393
(function (ts) {
9494
/* @internal */
@@ -84375,7 +84375,7 @@ var ts;
8437584375
var diagnosticsProducingTypeChecker;
8437684376
var noDiagnosticsTypeChecker;
8437784377
var classifiableNames;
84378-
var modifiedFilePaths;
84378+
var ambientModuleNameToUnmodifiedFileName = ts.createMap();
8437984379
var cachedSemanticDiagnosticsForFile = {};
8438084380
var cachedDeclarationDiagnosticsForFile = {};
8438184381
var resolvedTypeReferenceDirectives = ts.createMap();
@@ -84619,13 +84619,13 @@ var ts;
8461984619
}
8462084620
return classifiableNames;
8462184621
}
84622-
function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) {
84622+
function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) {
8462384623
if (structuralIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
8462484624
// If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
8462584625
// the best we can do is fallback to the default logic.
8462684626
return resolveModuleNamesWorker(moduleNames, containingFile);
8462784627
}
84628-
var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile);
84628+
var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile);
8462984629
if (oldSourceFile !== file && file.resolvedModules) {
8463084630
// `file` was created for the new program.
8463184631
//
@@ -84688,7 +84688,7 @@ var ts;
8468884688
}
8468984689
}
8469084690
else {
84691-
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState);
84691+
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
8469284692
}
8469384693
if (resolvesToAmbientModuleInNonModifiedFile) {
8469484694
(result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
@@ -84725,12 +84725,9 @@ var ts;
8472584725
return result;
8472684726
// If we change our policy of rechecking failed lookups on each program create,
8472784727
// we should adjust the value returned here.
84728-
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) {
84729-
if (!oldProgramState.program) {
84730-
return false;
84731-
}
84732-
var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217
84733-
var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName);
84728+
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
84729+
var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
84730+
var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
8473484731
if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) {
8473584732
// In the old program, we resolved to an ambient module that was in the same
8473684733
// place as we expected to find an actual module file.
@@ -84739,12 +84736,12 @@ var ts;
8473984736
return false;
8474084737
}
8474184738
// at least one of declarations should come from non-modified source file
84742-
var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); });
84743-
if (!firstUnmodifiedFile) {
84739+
var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
84740+
if (!unmodifiedFile) {
8474484741
return false;
8474584742
}
8474684743
if (ts.isTraceEnabled(options, host)) {
84747-
ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName);
84744+
ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
8474884745
}
8474984746
return true;
8475084747
}
@@ -84914,15 +84911,23 @@ var ts;
8491484911
if (oldProgram.structureIsReused !== 2 /* Completely */) {
8491584912
return oldProgram.structureIsReused;
8491684913
}
84917-
modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; });
84914+
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
84915+
for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
84916+
var oldFile = oldSourceFiles_3[_a];
84917+
if (!ts.contains(modifiedFiles, oldFile)) {
84918+
for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
84919+
var moduleName = _c[_b];
84920+
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
84921+
}
84922+
}
84923+
}
8491884924
// try to verify results of module resolution
84919-
for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) {
84920-
var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile;
84925+
for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
84926+
var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
8492184927
var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory);
8492284928
if (resolveModuleNamesWorker) {
8492384929
var moduleNames = getModuleNames(newSourceFile);
84924-
var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths };
84925-
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState);
84930+
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile);
8492684931
// ensure that module resolution results are still correct
8492784932
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
8492884933
if (resolutionsChanged) {
@@ -84965,8 +84970,8 @@ var ts;
8496584970
}
8496684971
files = newSourceFiles;
8496784972
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
84968-
for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) {
84969-
var modifiedFile = modifiedSourceFiles_2[_c];
84973+
for (var _f = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _f < modifiedSourceFiles_2.length; _f++) {
84974+
var modifiedFile = modifiedSourceFiles_2[_f];
8497084975
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
8497184976
}
8497284977
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
@@ -85874,8 +85879,7 @@ var ts;
8587485879
if (file.imports.length || file.moduleAugmentations.length) {
8587585880
// Because global augmentation doesn't have string literal name, we can check for global augmentation as such.
8587685881
var moduleNames = getModuleNames(file);
85877-
var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths };
85878-
var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState);
85882+
var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file);
8587985883
ts.Debug.assert(resolutions.length === moduleNames.length);
8588085884
for (var i = 0; i < moduleNames.length; i++) {
8588185885
var resolution = resolutions[i];

0 commit comments

Comments
 (0)