typescript 4.8.0-dev.20220518 → 4.8.0-dev.20220521

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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220518";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220521";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2432,6 +2432,7 @@ var ts;
2432
2432
  startsWith(candidate, prefix) &&
2433
2433
  endsWith(candidate, suffix);
2434
2434
  }
2435
+ ts.isPatternMatch = isPatternMatch;
2435
2436
  function and(f, g) {
2436
2437
  return function (arg) { return f(arg) && g(arg); };
2437
2438
  }
@@ -82810,7 +82811,7 @@ var ts;
82810
82811
  var childSymbol = getSymbolAtLocation(childNode);
82811
82812
  if (childSymbol && childSymbol === testedSymbol) {
82812
82813
  // If the test was a simple identifier, the above check is sufficient
82813
- if (ts.isIdentifier(expr)) {
82814
+ if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
82814
82815
  return true;
82815
82816
  }
82816
82817
  // Otherwise we need to ensure the symbol is called on the same target
@@ -116024,7 +116025,7 @@ var ts;
116024
116025
  };
116025
116026
  }
116026
116027
  // directoryExists
116027
- if (originalDirectoryExists && originalCreateDirectory) {
116028
+ if (originalDirectoryExists) {
116028
116029
  host.directoryExists = function (directory) {
116029
116030
  var key = toPath(directory);
116030
116031
  var value = directoryExistsCache.get(key);
@@ -116034,11 +116035,13 @@ var ts;
116034
116035
  directoryExistsCache.set(key, !!newValue);
116035
116036
  return newValue;
116036
116037
  };
116037
- host.createDirectory = function (directory) {
116038
- var key = toPath(directory);
116039
- directoryExistsCache.delete(key);
116040
- originalCreateDirectory.call(host, directory);
116041
- };
116038
+ if (originalCreateDirectory) {
116039
+ host.createDirectory = function (directory) {
116040
+ var key = toPath(directory);
116041
+ directoryExistsCache.delete(key);
116042
+ originalCreateDirectory.call(host, directory);
116043
+ };
116044
+ }
116042
116045
  }
116043
116046
  return {
116044
116047
  originalReadFile: originalReadFile,
@@ -128424,6 +128427,41 @@ var ts;
128424
128427
  return true;
128425
128428
  }
128426
128429
  ts.isTextWhiteSpaceLike = isTextWhiteSpaceLike;
128430
+ function getMappedLocation(location, sourceMapper, fileExists) {
128431
+ var mapsTo = sourceMapper.tryGetSourcePosition(location);
128432
+ return mapsTo && (!fileExists || fileExists(ts.normalizePath(mapsTo.fileName)) ? mapsTo : undefined);
128433
+ }
128434
+ ts.getMappedLocation = getMappedLocation;
128435
+ function getMappedDocumentSpan(documentSpan, sourceMapper, fileExists) {
128436
+ var fileName = documentSpan.fileName, textSpan = documentSpan.textSpan;
128437
+ var newPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start }, sourceMapper, fileExists);
128438
+ if (!newPosition)
128439
+ return undefined;
128440
+ var newEndPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start + textSpan.length }, sourceMapper, fileExists);
128441
+ var newLength = newEndPosition
128442
+ ? newEndPosition.pos - newPosition.pos
128443
+ : textSpan.length; // This shouldn't happen
128444
+ return {
128445
+ fileName: newPosition.fileName,
128446
+ textSpan: {
128447
+ start: newPosition.pos,
128448
+ length: newLength,
128449
+ },
128450
+ originalFileName: documentSpan.fileName,
128451
+ originalTextSpan: documentSpan.textSpan,
128452
+ contextSpan: getMappedContextSpan(documentSpan, sourceMapper, fileExists),
128453
+ originalContextSpan: documentSpan.contextSpan
128454
+ };
128455
+ }
128456
+ ts.getMappedDocumentSpan = getMappedDocumentSpan;
128457
+ function getMappedContextSpan(documentSpan, sourceMapper, fileExists) {
128458
+ var contextSpanStart = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start }, sourceMapper, fileExists);
128459
+ var contextSpanEnd = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length }, sourceMapper, fileExists);
128460
+ return contextSpanStart && contextSpanEnd ?
128461
+ { start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } :
128462
+ undefined;
128463
+ }
128464
+ ts.getMappedContextSpan = getMappedContextSpan;
128427
128465
  // #endregion
128428
128466
  // Display-part writer helpers
128429
128467
  // #region
@@ -131620,6 +131658,7 @@ var ts;
131620
131658
  * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
131621
131659
  */
131622
131660
  function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) {
131661
+ var _b;
131623
131662
  var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption;
131624
131663
  if (result === void 0) { result = []; }
131625
131664
  if (fragment === undefined) {
@@ -131637,9 +131676,26 @@ var ts;
131637
131676
  fragment = "." + ts.directorySeparator;
131638
131677
  }
131639
131678
  fragment = ts.ensureTrailingDirectorySeparator(fragment);
131640
- // const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); // TODO(rbuckton): should use resolvePaths
131641
131679
  var absolutePath = ts.resolvePath(scriptPath, fragment);
131642
131680
  var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath);
131681
+ // check for a version redirect
131682
+ var packageJsonPath = ts.findPackageJson(baseDirectory, host);
131683
+ if (packageJsonPath) {
131684
+ var packageJson = ts.readJson(packageJsonPath, host);
131685
+ var typesVersions = packageJson.typesVersions;
131686
+ if (typeof typesVersions === "object") {
131687
+ var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths;
131688
+ if (versionPaths) {
131689
+ var packageDirectory = ts.getDirectoryPath(packageJsonPath);
131690
+ var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
131691
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
131692
+ // A true result means one of the `versionPaths` was matched, which will block relative resolution
131693
+ // to files and folders from here. All reachable paths given the pattern match are already added.
131694
+ return result;
131695
+ }
131696
+ }
131697
+ }
131698
+ }
131643
131699
  var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
131644
131700
  if (!ts.tryDirectoryExists(host, baseDirectory))
131645
131701
  return result;
@@ -131681,48 +131737,62 @@ var ts;
131681
131737
  // If possible, get folder completion as well
131682
131738
  var directories = ts.tryGetDirectories(host, baseDirectory);
131683
131739
  if (directories) {
131684
- for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) {
131685
- var directory = directories_1[_b];
131740
+ for (var _c = 0, directories_1 = directories; _c < directories_1.length; _c++) {
131741
+ var directory = directories_1[_c];
131686
131742
  var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
131687
131743
  if (directoryName !== "@types") {
131688
131744
  result.push(directoryResult(directoryName));
131689
131745
  }
131690
131746
  }
131691
131747
  }
131692
- // check for a version redirect
131693
- var packageJsonPath = ts.findPackageJson(baseDirectory, host);
131694
- if (packageJsonPath) {
131695
- var packageJson = ts.readJson(packageJsonPath, host);
131696
- var typesVersions = packageJson.typesVersions;
131697
- if (typeof typesVersions === "object") {
131698
- var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions);
131699
- var versionPaths = versionResult && versionResult.paths;
131700
- var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length);
131701
- if (versionPaths) {
131702
- addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host);
131703
- }
131704
- }
131705
- }
131706
131748
  return result;
131707
131749
  }
131750
+ /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
131708
131751
  function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) {
131752
+ var _a;
131753
+ var pathResults = [];
131754
+ var matchedPathPrefixLength = -1;
131709
131755
  for (var path in paths) {
131710
131756
  if (!ts.hasProperty(paths, path))
131711
131757
  continue;
131712
131758
  var patterns = paths[path];
131713
131759
  if (patterns) {
131714
- var _loop_3 = function (name, kind, extension) {
131715
- // Path mappings may provide a duplicate way to get to something we've already added, so don't add again.
131716
- if (!result.some(function (entry) { return entry.name === name; })) {
131717
- result.push(nameAndKind(name, kind, extension));
131718
- }
131719
- };
131720
- for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) {
131721
- var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension;
131722
- _loop_3(name, kind, extension);
131760
+ var pathPattern = ts.tryParsePattern(path);
131761
+ if (!pathPattern)
131762
+ continue;
131763
+ var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
131764
+ var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
131765
+ if (isLongestMatch) {
131766
+ // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
131767
+ // for `import {} from "some-package/|"` with a typesVersions:
131768
+ // {
131769
+ // "bar/*": ["bar/*"], // <-- 1. We add 'bar', but 'bar/*' doesn't match yet.
131770
+ // "*": ["dist/*"], // <-- 2. We match here and add files from dist. 'bar' is still ok because it didn't come from a match.
131771
+ // "foo/*": ["foo/*"] // <-- 3. We matched '*' earlier and added results from dist, but if 'foo/*' also matched,
131772
+ // } results in dist would not be visible. 'bar' still stands because it didn't come from a match.
131773
+ // This is especially important if `dist/foo` is a folder, because if we fail to clear results
131774
+ // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
131775
+ // ./dist/foo and ./foo, when only the latter will actually be resolvable.
131776
+ // See pathCompletionsTypesVersionsWildcard6.ts.
131777
+ matchedPathPrefixLength = pathPattern.prefix.length;
131778
+ pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
131779
+ }
131780
+ if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
131781
+ pathResults.push({
131782
+ matchedPattern: isMatch,
131783
+ results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
131784
+ .map(function (_a) {
131785
+ var name = _a.name, kind = _a.kind, extension = _a.extension;
131786
+ return nameAndKind(name, kind, extension);
131787
+ }),
131788
+ });
131723
131789
  }
131724
131790
  }
131725
131791
  }
131792
+ var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
131793
+ var equateResults = function (a, b) { return equatePaths(a.name, b.name); };
131794
+ pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
131795
+ return matchedPathPrefixLength > -1;
131726
131796
  }
131727
131797
  /**
131728
131798
  * Check all of the declared modules and those in node modules. Possible sources of modules:
@@ -131754,7 +131824,7 @@ var ts;
131754
131824
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
131755
131825
  var foundGlobal = false;
131756
131826
  if (fragmentDirectory === undefined) {
131757
- var _loop_4 = function (moduleName) {
131827
+ var _loop_3 = function (moduleName) {
131758
131828
  if (!result.some(function (entry) { return entry.name === moduleName; })) {
131759
131829
  foundGlobal = true;
131760
131830
  result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
@@ -131762,7 +131832,7 @@ var ts;
131762
131832
  };
131763
131833
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
131764
131834
  var moduleName = _c[_b];
131765
- _loop_4(moduleName);
131835
+ _loop_3(moduleName);
131766
131836
  }
131767
131837
  }
131768
131838
  if (!foundGlobal) {
@@ -131842,11 +131912,16 @@ var ts;
131842
131912
  }
131843
131913
  var pathPrefix = path.slice(0, path.length - 1);
131844
131914
  var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
131845
- return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) {
131846
- return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host);
131847
- });
131915
+ if (remainingFragment === undefined) {
131916
+ var starIsFullPathComponent = path[path.length - 2] === "/";
131917
+ return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
131918
+ var name = _a.name, rest = __rest(_a, ["name"]);
131919
+ return (__assign({ name: pathPrefix + name }, rest));
131920
+ }); });
131921
+ }
131922
+ return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); });
131848
131923
  function justPathMappingName(name) {
131849
- return ts.startsWith(name, fragment) ? [directoryResult(name)] : ts.emptyArray;
131924
+ return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray;
131850
131925
  }
131851
131926
  }
131852
131927
  function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) {
@@ -137345,6 +137420,7 @@ var ts;
137345
137420
  var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined;
137346
137421
  return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; })));
137347
137422
  }
137423
+ FindAllReferences.isDeclarationOfSymbol = isDeclarationOfSymbol;
137348
137424
  /**
137349
137425
  * True if 'decl' provides a value, as in `function f() {}`;
137350
137426
  * false if 'decl' is just a location for a future write, as in 'let x;'
@@ -137551,7 +137627,7 @@ var ts;
137551
137627
  result = references;
137552
137628
  continue;
137553
137629
  }
137554
- var _loop_5 = function (entry) {
137630
+ var _loop_4 = function (entry) {
137555
137631
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
137556
137632
  result.push(entry);
137557
137633
  return "continue";
@@ -137583,7 +137659,7 @@ var ts;
137583
137659
  };
137584
137660
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
137585
137661
  var entry = references_2[_b];
137586
- _loop_5(entry);
137662
+ _loop_4(entry);
137587
137663
  }
137588
137664
  }
137589
137665
  return result;
@@ -139611,7 +139687,7 @@ var ts;
139611
139687
  }
139612
139688
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
139613
139689
  var allFiles = program.getSourceFiles();
139614
- var _loop_6 = function (sourceFile) {
139690
+ var _loop_5 = function (sourceFile) {
139615
139691
  var newFromOld = oldToNew(sourceFile.fileName);
139616
139692
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
139617
139693
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -139643,7 +139719,7 @@ var ts;
139643
139719
  };
139644
139720
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
139645
139721
  var sourceFile = allFiles_1[_i];
139646
- _loop_6(sourceFile);
139722
+ _loop_5(sourceFile);
139647
139723
  }
139648
139724
  }
139649
139725
  function combineNormal(pathA, pathB) {
@@ -140667,7 +140743,7 @@ var ts;
140667
140743
  if (!patternMatcher)
140668
140744
  return ts.emptyArray;
140669
140745
  var rawItems = [];
140670
- var _loop_7 = function (sourceFile) {
140746
+ var _loop_6 = function (sourceFile) {
140671
140747
  cancellationToken.throwIfCancellationRequested();
140672
140748
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
140673
140749
  return "continue";
@@ -140679,7 +140755,7 @@ var ts;
140679
140755
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
140680
140756
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
140681
140757
  var sourceFile = sourceFiles_4[_i];
140682
- _loop_7(sourceFile);
140758
+ _loop_6(sourceFile);
140683
140759
  }
140684
140760
  rawItems.sort(compareNavigateToItems);
140685
140761
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -142744,13 +142820,13 @@ var ts;
142744
142820
  // Assumes 'value' is already lowercase.
142745
142821
  function indexOfIgnoringCase(str, value) {
142746
142822
  var n = str.length - value.length;
142747
- var _loop_8 = function (start) {
142823
+ var _loop_7 = function (start) {
142748
142824
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
142749
142825
  return { value: start };
142750
142826
  }
142751
142827
  };
142752
142828
  for (var start = 0; start <= n; start++) {
142753
- var state_3 = _loop_8(start);
142829
+ var state_3 = _loop_7(start);
142754
142830
  if (typeof state_3 === "object")
142755
142831
  return state_3.value;
142756
142832
  }
@@ -144169,7 +144245,7 @@ var ts;
144169
144245
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
144170
144246
  }
144171
144247
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
144172
- var _loop_9 = function (n) {
144248
+ var _loop_8 = function (n) {
144173
144249
  // If the node is not a subspan of its parent, this is a big problem.
144174
144250
  // There have been crashes that might be caused by this violation.
144175
144251
  ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
@@ -144179,7 +144255,7 @@ var ts;
144179
144255
  }
144180
144256
  };
144181
144257
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
144182
- var state_4 = _loop_9(n);
144258
+ var state_4 = _loop_8(n);
144183
144259
  if (typeof state_4 === "object")
144184
144260
  return state_4.value;
144185
144261
  }
@@ -145778,7 +145854,7 @@ var ts;
145778
145854
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
145779
145855
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
145780
145856
  options = ts.cloneCompilerOptions(options);
145781
- var _loop_10 = function (opt) {
145857
+ var _loop_9 = function (opt) {
145782
145858
  if (!ts.hasProperty(options, opt.name)) {
145783
145859
  return "continue";
145784
145860
  }
@@ -145797,7 +145873,7 @@ var ts;
145797
145873
  };
145798
145874
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
145799
145875
  var opt = commandLineOptionsStringToEnum_1[_i];
145800
- _loop_10(opt);
145876
+ _loop_9(opt);
145801
145877
  }
145802
145878
  return options;
145803
145879
  }
@@ -149545,7 +149621,7 @@ var ts;
149545
149621
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
149546
149622
  var _this = this;
149547
149623
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
149548
- var _loop_11 = function (sourceFile, node) {
149624
+ var _loop_10 = function (sourceFile, node) {
149549
149625
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
149550
149626
  if (ts.isArray(node)) {
149551
149627
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -149558,7 +149634,7 @@ var ts;
149558
149634
  var this_1 = this;
149559
149635
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
149560
149636
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
149561
- _loop_11(sourceFile, node);
149637
+ _loop_10(sourceFile, node);
149562
149638
  }
149563
149639
  deletedNodesInLists.forEach(function (node) {
149564
149640
  var sourceFile = node.getSourceFile();
@@ -149646,14 +149722,14 @@ var ts;
149646
149722
  // order changes by start position
149647
149723
  // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa.
149648
149724
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
149649
- var _loop_12 = function (i) {
149725
+ var _loop_11 = function (i) {
149650
149726
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
149651
149727
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
149652
149728
  });
149653
149729
  };
149654
149730
  // verify that change intervals do not overlap, except possibly at end points.
149655
149731
  for (var i = 0; i < normalized.length - 1; i++) {
149656
- _loop_12(i);
149732
+ _loop_11(i);
149657
149733
  }
149658
149734
  var textChanges = ts.mapDefined(normalized, function (c) {
149659
149735
  var span = ts.createTextSpanFromRange(c.range);
@@ -150562,7 +150638,7 @@ var ts;
150562
150638
  }
150563
150639
  var isCompleteFix = identifiers.isCompleteFix;
150564
150640
  var initializers;
150565
- var _loop_13 = function (identifier) {
150641
+ var _loop_12 = function (identifier) {
150566
150642
  var symbol = checker.getSymbolAtLocation(identifier);
150567
150643
  if (!symbol) {
150568
150644
  return "continue";
@@ -150595,7 +150671,7 @@ var ts;
150595
150671
  };
150596
150672
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
150597
150673
  var identifier = _a[_i];
150598
- _loop_13(identifier);
150674
+ _loop_12(identifier);
150599
150675
  }
150600
150676
  return initializers && {
150601
150677
  initializers: initializers,
@@ -151485,7 +151561,7 @@ var ts;
151485
151561
  functionToConvert.getStart(sourceFile);
151486
151562
  var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " };
151487
151563
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options);
151488
- var _loop_14 = function (returnStatement) {
151564
+ var _loop_13 = function (returnStatement) {
151489
151565
  ts.forEachChild(returnStatement, function visit(node) {
151490
151566
  if (ts.isCallExpression(node)) {
151491
151567
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -151507,7 +151583,7 @@ var ts;
151507
151583
  };
151508
151584
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
151509
151585
  var returnStatement = returnStatements_1[_i];
151510
- var state_5 = _loop_14(returnStatement);
151586
+ var state_5 = _loop_13(returnStatement);
151511
151587
  if (typeof state_5 === "object")
151512
151588
  return state_5.value;
151513
151589
  }
@@ -154755,7 +154831,7 @@ var ts;
154755
154831
  });
154756
154832
  typeDeclToMembers.forEach(function (infos, declaration) {
154757
154833
  var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
154758
- var _loop_15 = function (info) {
154834
+ var _loop_14 = function (info) {
154759
154835
  // If some superclass added this property, don't add it again.
154760
154836
  if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
154761
154837
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -154782,7 +154858,7 @@ var ts;
154782
154858
  };
154783
154859
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
154784
154860
  var info = infos_1[_i];
154785
- _loop_15(info);
154861
+ _loop_14(info);
154786
154862
  }
154787
154863
  });
154788
154864
  }));
@@ -157545,7 +157621,7 @@ var ts;
157545
157621
  function getSignatureFromCalls(calls) {
157546
157622
  var parameters = [];
157547
157623
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
157548
- var _loop_16 = function (i) {
157624
+ var _loop_15 = function (i) {
157549
157625
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
157550
157626
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
157551
157627
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -157554,7 +157630,7 @@ var ts;
157554
157630
  parameters.push(symbol);
157555
157631
  };
157556
157632
  for (var i = 0; i < length; i++) {
157557
- _loop_16(i);
157633
+ _loop_15(i);
157558
157634
  }
157559
157635
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
157560
157636
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -159527,7 +159603,7 @@ var ts;
159527
159603
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
159528
159604
  // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`.
159529
159605
  var neededNamedImports = new ts.Set();
159530
- var _loop_17 = function (element) {
159606
+ var _loop_16 = function (element) {
159531
159607
  var propertyName = (element.propertyName || element.name).text;
159532
159608
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
159533
159609
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -159544,7 +159620,7 @@ var ts;
159544
159620
  };
159545
159621
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
159546
159622
  var element = _a[_i];
159547
- _loop_17(element);
159623
+ _loop_16(element);
159548
159624
  }
159549
159625
  changes.replaceNode(sourceFile, toConvert, shouldUseDefault
159550
159626
  ? ts.factory.createIdentifier(namespaceImportName)
@@ -161442,7 +161518,7 @@ var ts;
161442
161518
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
161443
161519
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
161444
161520
  }
161445
- var _loop_18 = function (i) {
161521
+ var _loop_17 = function (i) {
161446
161522
  var scopeUsages = usagesPerScope[i];
161447
161523
  // Special case: in the innermost scope, all usages are available.
161448
161524
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -161485,7 +161561,7 @@ var ts;
161485
161561
  }
161486
161562
  };
161487
161563
  for (var i = 0; i < scopes.length; i++) {
161488
- _loop_18(i);
161564
+ _loop_17(i);
161489
161565
  }
161490
161566
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
161491
161567
  function isInGenericContext(node) {
@@ -162188,10 +162264,10 @@ var ts;
162188
162264
  }
162189
162265
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
162190
162266
  var checker = program.getTypeChecker();
162191
- var _loop_19 = function (sourceFile) {
162267
+ var _loop_18 = function (sourceFile) {
162192
162268
  if (sourceFile === oldFile)
162193
162269
  return "continue";
162194
- var _loop_20 = function (statement) {
162270
+ var _loop_19 = function (statement) {
162195
162271
  forEachImportInStatement(statement, function (importNode) {
162196
162272
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
162197
162273
  return;
@@ -162213,12 +162289,12 @@ var ts;
162213
162289
  };
162214
162290
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
162215
162291
  var statement = _c[_b];
162216
- _loop_20(statement);
162292
+ _loop_19(statement);
162217
162293
  }
162218
162294
  };
162219
162295
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
162220
162296
  var sourceFile = _a[_i];
162221
- _loop_19(sourceFile);
162297
+ _loop_18(sourceFile);
162222
162298
  }
162223
162299
  }
162224
162300
  function getNamespaceLikeImport(node) {
@@ -163582,7 +163658,7 @@ var ts;
163582
163658
  var templateSpans = [];
163583
163659
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
163584
163660
  copyCommentFromStringLiterals(headIndexes, templateHead);
163585
- var _loop_21 = function (i) {
163661
+ var _loop_20 = function (i) {
163586
163662
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
163587
163663
  copyOperatorComments(i, currentNode);
163588
163664
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -163611,7 +163687,7 @@ var ts;
163611
163687
  };
163612
163688
  var out_i_1;
163613
163689
  for (var i = begin; i < nodes.length; i++) {
163614
- _loop_21(i);
163690
+ _loop_20(i);
163615
163691
  i = out_i_1;
163616
163692
  }
163617
163693
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -164447,7 +164523,7 @@ var ts;
164447
164523
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
164448
164524
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
164449
164525
  var seenSymbols_1 = new ts.Set();
164450
- var _loop_22 = function (declaration) {
164526
+ var _loop_21 = function (declaration) {
164451
164527
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
164452
164528
  var _a;
164453
164529
  if (!seenSymbols_1.has(symbol)) {
@@ -164464,7 +164540,7 @@ var ts;
164464
164540
  };
164465
164541
  for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
164466
164542
  var declaration = declarations_6[_i];
164467
- _loop_22(declaration);
164543
+ _loop_21(declaration);
164468
164544
  }
164469
164545
  }
164470
164546
  return tags;
@@ -164475,7 +164551,7 @@ var ts;
164475
164551
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
164476
164552
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
164477
164553
  var seenSymbols_2 = new ts.Set();
164478
- var _loop_23 = function (declaration) {
164554
+ var _loop_22 = function (declaration) {
164479
164555
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
164480
164556
  if (!seenSymbols_2.has(symbol)) {
164481
164557
  seenSymbols_2.add(symbol);
@@ -164491,7 +164567,7 @@ var ts;
164491
164567
  };
164492
164568
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
164493
164569
  var declaration = declarations_7[_i];
164494
- _loop_23(declaration);
164570
+ _loop_22(declaration);
164495
164571
  }
164496
164572
  }
164497
164573
  return doc;
@@ -164748,70 +164824,6 @@ var ts;
164748
164824
  return ts.codefix.getSupportedErrorCodes();
164749
164825
  }
164750
164826
  ts.getSupportedCodeFixes = getSupportedCodeFixes;
164751
- // Cache host information about script Should be refreshed
164752
- // at each language service public entry point, since we don't know when
164753
- // the set of scripts handled by the host changes.
164754
- var HostCache = /** @class */ (function () {
164755
- function HostCache(host, getCanonicalFileName) {
164756
- this.host = host;
164757
- // script id => script index
164758
- this.currentDirectory = host.getCurrentDirectory();
164759
- this.fileNameToEntry = new ts.Map();
164760
- // Initialize the list with the root file names
164761
- var rootFileNames = host.getScriptFileNames();
164762
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
164763
- for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
164764
- var fileName = rootFileNames_1[_i];
164765
- this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
164766
- }
164767
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
164768
- }
164769
- HostCache.prototype.createEntry = function (fileName, path) {
164770
- var entry;
164771
- var scriptSnapshot = this.host.getScriptSnapshot(fileName);
164772
- if (scriptSnapshot) {
164773
- entry = {
164774
- hostFileName: fileName,
164775
- version: this.host.getScriptVersion(fileName),
164776
- scriptSnapshot: scriptSnapshot,
164777
- scriptKind: ts.getScriptKind(fileName, this.host)
164778
- };
164779
- }
164780
- else {
164781
- entry = fileName;
164782
- }
164783
- this.fileNameToEntry.set(path, entry);
164784
- return entry;
164785
- };
164786
- HostCache.prototype.getEntryByPath = function (path) {
164787
- return this.fileNameToEntry.get(path);
164788
- };
164789
- HostCache.prototype.getHostFileInformation = function (path) {
164790
- var entry = this.fileNameToEntry.get(path);
164791
- return !ts.isString(entry) ? entry : undefined;
164792
- };
164793
- HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) {
164794
- var info = this.getEntryByPath(path) || this.createEntry(fileName, path);
164795
- return ts.isString(info) ? undefined : info; // TODO: GH#18217
164796
- };
164797
- HostCache.prototype.getRootFileNames = function () {
164798
- var names = [];
164799
- this.fileNameToEntry.forEach(function (entry) {
164800
- if (ts.isString(entry)) {
164801
- names.push(entry);
164802
- }
164803
- else {
164804
- names.push(entry.hostFileName);
164805
- }
164806
- });
164807
- return names;
164808
- };
164809
- HostCache.prototype.getScriptSnapshot = function (path) {
164810
- var file = this.getHostFileInformation(path);
164811
- return (file && file.scriptSnapshot); // TODO: GH#18217
164812
- };
164813
- return HostCache;
164814
- }());
164815
164827
  var SyntaxTreeCache = /** @class */ (function () {
164816
164828
  function SyntaxTreeCache(host) {
164817
164829
  this.host = host;
@@ -165073,32 +165085,13 @@ var ts;
165073
165085
  program = undefined; // TODO: GH#18217
165074
165086
  lastTypesRootVersion = typeRootsVersion;
165075
165087
  }
165088
+ var rootFileNames = host.getScriptFileNames();
165076
165089
  // Get a fresh cache of the host information
165077
- var hostCache = new HostCache(host, getCanonicalFileName);
165078
- var rootFileNames = hostCache.getRootFileNames();
165079
165090
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
165080
165091
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
165081
165092
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
165082
165093
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
165083
165094
  var parsedCommandLines;
165084
- var parseConfigHost = {
165085
- useCaseSensitiveFileNames: useCaseSensitiveFileNames,
165086
- fileExists: fileExists,
165087
- readFile: readFile,
165088
- readDirectory: readDirectory,
165089
- trace: ts.maybeBind(host, host.trace),
165090
- getCurrentDirectory: function () { return currentDirectory; },
165091
- onUnRecoverableConfigFileDiagnostic: ts.noop,
165092
- };
165093
- // If the program is already up-to-date, we can reuse it
165094
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
165095
- return;
165096
- }
165097
- // IMPORTANT - It is critical from this moment onward that we do not check
165098
- // cancellation tokens. We are about to mutate source files from a previous program
165099
- // instance. If we cancel midway through, we may end up in an inconsistent state where
165100
- // the program points to old source files that have been invalidated because of
165101
- // incremental parsing.
165102
165095
  // Now create a new compiler
165103
165096
  var compilerHost = {
165104
165097
  getSourceFile: getOrCreateSourceFile,
@@ -165110,8 +165103,8 @@ var ts;
165110
165103
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
165111
165104
  writeFile: ts.noop,
165112
165105
  getCurrentDirectory: function () { return currentDirectory; },
165113
- fileExists: fileExists,
165114
- readFile: readFile,
165106
+ fileExists: function (fileName) { return host.fileExists(fileName); },
165107
+ readFile: function (fileName) { return host.readFile && host.readFile(fileName); },
165115
165108
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
165116
165109
  realpath: ts.maybeBind(host, host.realpath),
165117
165110
  directoryExists: function (directoryName) {
@@ -165120,19 +165113,56 @@ var ts;
165120
165113
  getDirectories: function (path) {
165121
165114
  return host.getDirectories ? host.getDirectories(path) : [];
165122
165115
  },
165123
- readDirectory: readDirectory,
165116
+ readDirectory: function (path, extensions, exclude, include, depth) {
165117
+ ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
165118
+ return host.readDirectory(path, extensions, exclude, include, depth);
165119
+ },
165124
165120
  onReleaseOldSourceFile: onReleaseOldSourceFile,
165125
165121
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
165126
165122
  hasInvalidatedResolution: hasInvalidatedResolution,
165127
165123
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
165128
- trace: parseConfigHost.trace,
165124
+ trace: ts.maybeBind(host, host.trace),
165129
165125
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
165130
165126
  getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
165131
165127
  resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
165132
165128
  useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
165133
165129
  getParsedCommandLine: getParsedCommandLine,
165134
165130
  };
165131
+ var originalGetSourceFile = compilerHost.getSourceFile;
165132
+ var getSourceFileWithCache = ts.changeCompilerHostLikeToUseCache(compilerHost, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); }, function () {
165133
+ var args = [];
165134
+ for (var _i = 0; _i < arguments.length; _i++) {
165135
+ args[_i] = arguments[_i];
165136
+ }
165137
+ return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args, false));
165138
+ }).getSourceFileWithCache;
165139
+ compilerHost.getSourceFile = getSourceFileWithCache;
165135
165140
  (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost);
165141
+ var parseConfigHost = {
165142
+ useCaseSensitiveFileNames: useCaseSensitiveFileNames,
165143
+ fileExists: function (fileName) { return compilerHost.fileExists(fileName); },
165144
+ readFile: function (fileName) { return compilerHost.readFile(fileName); },
165145
+ readDirectory: function () {
165146
+ var _a;
165147
+ var args = [];
165148
+ for (var _i = 0; _i < arguments.length; _i++) {
165149
+ args[_i] = arguments[_i];
165150
+ }
165151
+ return (_a = compilerHost).readDirectory.apply(_a, args);
165152
+ },
165153
+ trace: compilerHost.trace,
165154
+ getCurrentDirectory: compilerHost.getCurrentDirectory,
165155
+ onUnRecoverableConfigFileDiagnostic: ts.noop,
165156
+ };
165157
+ // If the program is already up-to-date, we can reuse it
165158
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
165159
+ return;
165160
+ }
165161
+ // IMPORTANT - It is critical from this moment onward that we do not check
165162
+ // cancellation tokens. We are about to mutate source files from a previous program
165163
+ // instance. If we cancel midway through, we may end up in an inconsistent state where
165164
+ // the program points to old source files that have been invalidated because of
165165
+ // incremental parsing.
165136
165166
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
165137
165167
  var options = {
165138
165168
  rootNames: rootFileNames,
@@ -165142,9 +165172,9 @@ var ts;
165142
165172
  projectReferences: projectReferences
165143
165173
  };
165144
165174
  program = ts.createProgram(options);
165145
- // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
165146
- // It needs to be cleared to allow all collected snapshots to be released
165147
- hostCache = undefined;
165175
+ // 'getOrCreateSourceFile' depends on caching but should be used past this point.
165176
+ // After this point, the cache needs to be cleared to allow all collected snapshots to be released
165177
+ compilerHost = undefined;
165148
165178
  parsedCommandLines = undefined;
165149
165179
  // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above,
165150
165180
  // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during
@@ -165184,26 +165214,6 @@ var ts;
165184
165214
  onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
165185
165215
  }
165186
165216
  }
165187
- function fileExists(fileName) {
165188
- var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
165189
- var entry = hostCache && hostCache.getEntryByPath(path);
165190
- return entry ?
165191
- !ts.isString(entry) :
165192
- (!!host.fileExists && host.fileExists(fileName));
165193
- }
165194
- function readFile(fileName) {
165195
- // stub missing host functionality
165196
- var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
165197
- var entry = hostCache && hostCache.getEntryByPath(path);
165198
- if (entry) {
165199
- return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot);
165200
- }
165201
- return host.readFile && host.readFile(fileName);
165202
- }
165203
- function readDirectory(path, extensions, exclude, include, depth) {
165204
- ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
165205
- return host.readDirectory(path, extensions, exclude, include, depth);
165206
- }
165207
165217
  // Release any files we have acquired in the old program but are
165208
165218
  // not part of the new program.
165209
165219
  function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
@@ -165214,14 +165224,16 @@ var ts;
165214
165224
  return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile);
165215
165225
  }
165216
165226
  function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) {
165217
- ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
165227
+ ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
165218
165228
  // The program is asking for this file, check first if the host can locate it.
165219
165229
  // If the host can not locate the file, then it does not exist. return undefined
165220
165230
  // to the program to allow reporting of errors for missing files.
165221
- var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path);
165222
- if (!hostFileInformation) {
165231
+ var scriptSnapshot = host.getScriptSnapshot(fileName);
165232
+ if (!scriptSnapshot) {
165223
165233
  return undefined;
165224
165234
  }
165235
+ var scriptKind = ts.getScriptKind(fileName, host);
165236
+ var scriptVersion = host.getScriptVersion(fileName);
165225
165237
  // Check if the language version has changed since we last created a program; if they are the same,
165226
165238
  // it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile
165227
165239
  // can not be reused. we have to dump all syntax trees and create new ones.
@@ -165253,8 +165265,8 @@ var ts;
165253
165265
  // We do not support the scenario where a host can modify a registered
165254
165266
  // file's script kind, i.e. in one project some file is treated as ".ts"
165255
165267
  // and in another as ".js"
165256
- if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
165257
- return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
165268
+ if (scriptKind === oldSourceFile.scriptKind) {
165269
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
165258
165270
  }
165259
165271
  else {
165260
165272
  // Release old source file and fall through to aquire new file with new script kind
@@ -165264,7 +165276,7 @@ var ts;
165264
165276
  // We didn't already have the file. Fall through and acquire it from the registry.
165265
165277
  }
165266
165278
  // Could not find this file in the old program, create a new SourceFile for it.
165267
- return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
165279
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
165268
165280
  }
165269
165281
  }
165270
165282
  // TODO: GH#18217 frequently asserted as defined
@@ -165280,6 +165292,61 @@ var ts;
165280
165292
  var _a;
165281
165293
  return (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host);
165282
165294
  }
165295
+ function updateIsDefinitionOfReferencedSymbols(referencedSymbols, knownSymbolSpans) {
165296
+ var checker = program.getTypeChecker();
165297
+ var symbol = getSymbolForProgram();
165298
+ if (!symbol)
165299
+ return false;
165300
+ for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) {
165301
+ var referencedSymbol = referencedSymbols_1[_i];
165302
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
165303
+ var ref = _b[_a];
165304
+ var refNode = getNodeForSpan(ref);
165305
+ ts.Debug.assertIsDefined(refNode);
165306
+ if (knownSymbolSpans.has(ref) || ts.FindAllReferences.isDeclarationOfSymbol(refNode, symbol)) {
165307
+ knownSymbolSpans.add(ref);
165308
+ ref.isDefinition = true;
165309
+ var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
165310
+ if (mappedSpan) {
165311
+ knownSymbolSpans.add(mappedSpan);
165312
+ }
165313
+ }
165314
+ else {
165315
+ ref.isDefinition = false;
165316
+ }
165317
+ }
165318
+ }
165319
+ return true;
165320
+ function getSymbolForProgram() {
165321
+ for (var _i = 0, referencedSymbols_2 = referencedSymbols; _i < referencedSymbols_2.length; _i++) {
165322
+ var referencedSymbol = referencedSymbols_2[_i];
165323
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
165324
+ var ref = _b[_a];
165325
+ if (knownSymbolSpans.has(ref)) {
165326
+ var refNode = getNodeForSpan(ref);
165327
+ ts.Debug.assertIsDefined(refNode);
165328
+ return checker.getSymbolAtLocation(refNode);
165329
+ }
165330
+ var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
165331
+ if (mappedSpan && knownSymbolSpans.has(mappedSpan)) {
165332
+ var refNode = getNodeForSpan(mappedSpan);
165333
+ if (refNode) {
165334
+ return checker.getSymbolAtLocation(refNode);
165335
+ }
165336
+ }
165337
+ }
165338
+ }
165339
+ return undefined;
165340
+ }
165341
+ function getNodeForSpan(docSpan) {
165342
+ var sourceFile = program.getSourceFile(docSpan.fileName);
165343
+ if (!sourceFile)
165344
+ return undefined;
165345
+ var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start);
165346
+ var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ });
165347
+ return adjustedNode;
165348
+ }
165349
+ }
165283
165350
  function cleanupSemanticCache() {
165284
165351
  program = undefined; // TODO: GH#18217
165285
165352
  }
@@ -166206,6 +166273,7 @@ var ts;
166206
166273
  getNonBoundSourceFile: getNonBoundSourceFile,
166207
166274
  getProgram: getProgram,
166208
166275
  getAutoImportProvider: getAutoImportProvider,
166276
+ updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
166209
166277
  getApplicableRefactors: getApplicableRefactors,
166210
166278
  getEditsForRefactor: getEditsForRefactor,
166211
166279
  toLineColumnOffset: toLineColumnOffset,