@typescript-deploys/pr-build 4.8.0-pr-49157-6 → 4.8.0-pr-49233-9

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/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220518";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -2238,6 +2238,7 @@ var ts;
2238
2238
  startsWith(candidate, prefix) &&
2239
2239
  endsWith(candidate, suffix);
2240
2240
  }
2241
+ ts.isPatternMatch = isPatternMatch;
2241
2242
  function and(f, g) {
2242
2243
  return function (arg) { return f(arg) && g(arg); };
2243
2244
  }
@@ -43147,16 +43148,20 @@ var ts;
43147
43148
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43148
43149
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43149
43150
  }
43151
+ var jsOnlyExtensions = [Extensions.JavaScript];
43152
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43153
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43154
+ var tsconfigExtensions = [Extensions.TSConfig];
43150
43155
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43151
43156
  var containingDirectory = ts.getDirectoryPath(containingFile);
43152
43157
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43153
43158
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43154
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43159
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43160
+ if (compilerOptions.resolveJsonModule) {
43161
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43162
+ }
43163
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43155
43164
  }
43156
- var jsOnlyExtensions = [Extensions.JavaScript];
43157
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43158
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43159
- var tsconfigExtensions = [Extensions.TSConfig];
43160
43165
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43161
43166
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43162
43167
  }
@@ -62183,7 +62188,7 @@ var ts;
62183
62188
  function substituteIndexedMappedType(objectType, index) {
62184
62189
  var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
62185
62190
  var templateMapper = combineTypeMappers(objectType.mapper, mapper);
62186
- return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
62191
+ return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper);
62187
62192
  }
62188
62193
  function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
62189
62194
  if (accessFlags === void 0) { accessFlags = 0 /* None */; }
@@ -72295,7 +72300,7 @@ var ts;
72295
72300
  if (result) {
72296
72301
  return result;
72297
72302
  }
72298
- if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
72303
+ if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
72299
72304
  return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
72300
72305
  }
72301
72306
  }
@@ -72764,22 +72769,20 @@ var ts;
72764
72769
  var inferenceContext = getInferenceContext(node);
72765
72770
  // If no inferences have been made, nothing is gained from instantiating as type parameters
72766
72771
  // would just be replaced with their defaults similar to the apparent type.
72767
- if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
72772
+ if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
72768
72773
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
72769
72774
  // types as well as arguments to the left in a function call.
72770
- if (contextFlags && contextFlags & 1 /* Signature */) {
72771
- return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
72772
- }
72775
+ return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
72776
+ }
72777
+ if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
72773
72778
  // For other purposes (e.g. determining whether to produce literal types) we only
72774
72779
  // incorporate inferences made from the return type in a function call. We remove
72775
72780
  // the 'boolean' type from the contextual type such that contextually typed boolean
72776
72781
  // literals actually end up widening to 'boolean' (see #48363).
72777
- if (inferenceContext.returnMapper) {
72778
- var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72779
- return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
72780
- filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
72781
- type;
72782
- }
72782
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72783
+ return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
72784
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
72785
+ type;
72783
72786
  }
72784
72787
  }
72785
72788
  return contextualType;
@@ -75313,29 +75316,43 @@ var ts;
75313
75316
  // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
75314
75317
  // return type of 'wrap'.
75315
75318
  if (node.kind !== 165 /* Decorator */) {
75316
- var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75319
+ var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
75320
+ var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75317
75321
  if (contextualType) {
75318
75322
  var inferenceTargetType = getReturnTypeOfSignature(signature);
75319
75323
  if (couldContainTypeVariables(inferenceTargetType)) {
75320
- // We clone the inference context to avoid disturbing a resolution in progress for an
75321
- // outer call expression. Effectively we just want a snapshot of whatever has been
75322
- // inferred for any outer call expression so far.
75323
75324
  var outerContext = getInferenceContext(node);
75324
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75325
- var instantiatedType = instantiateType(contextualType, outerMapper);
75326
- // If the contextual type is a generic function type with a single call signature, we
75327
- // instantiate the type with its own type parameters and type arguments. This ensures that
75328
- // the type parameters are not erased to type any during type inference such that they can
75329
- // be inferred as actual types from the contextual type. For example:
75330
- // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75331
- // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75332
- // Above, the type of the 'value' parameter is inferred to be 'A'.
75333
- var contextualSignature = getSingleCallSignature(instantiatedType);
75334
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75335
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75336
- instantiatedType;
75337
- // Inferences made from return types have lower priority than all other inferences.
75338
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75325
+ var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
75326
+ // A return type inference from a binding pattern can be used in instantiating the contextual
75327
+ // type of an argument later in inference, but cannot stand on its own as the final return type.
75328
+ // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
75329
+ // but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
75330
+ // produce a tuple for `T` in
75331
+ // declare function f<T>(cb: () => T): T;
75332
+ // const [e1, e2, e3] = f(() => [1, "hi", true]);
75333
+ // but does not produce any inference for `T` in
75334
+ // declare function f<T>(): T;
75335
+ // const [e1, e2, e3] = f();
75336
+ if (!isFromBindingPattern) {
75337
+ // We clone the inference context to avoid disturbing a resolution in progress for an
75338
+ // outer call expression. Effectively we just want a snapshot of whatever has been
75339
+ // inferred for any outer call expression so far.
75340
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75341
+ var instantiatedType = instantiateType(contextualType, outerMapper);
75342
+ // If the contextual type is a generic function type with a single call signature, we
75343
+ // instantiate the type with its own type parameters and type arguments. This ensures that
75344
+ // the type parameters are not erased to type any during type inference such that they can
75345
+ // be inferred as actual types from the contextual type. For example:
75346
+ // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75347
+ // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75348
+ // Above, the type of the 'value' parameter is inferred to be 'A'.
75349
+ var contextualSignature = getSingleCallSignature(instantiatedType);
75350
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75351
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75352
+ instantiatedType;
75353
+ // Inferences made from return types have lower priority than all other inferences.
75354
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75355
+ }
75339
75356
  // Create a type mapper for instantiating generic contextual types using the inferences made
75340
75357
  // from the return type. We need a separate inference pass here because (a) instantiation of
75341
75358
  // the source type uses the outer context's return mapper (which excludes inferences made from
@@ -107260,7 +107277,7 @@ var ts;
107260
107277
  // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
107261
107278
  // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
107262
107279
  // is available, just because the output is reasonable for a node-like runtime.
107263
- return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
107280
+ return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
107264
107281
  case 271 /* ExportAssignment */:
107265
107282
  return visitExportAssignment(node);
107266
107283
  case 272 /* ExportDeclaration */:
@@ -115830,7 +115847,7 @@ var ts;
115830
115847
  };
115831
115848
  }
115832
115849
  // directoryExists
115833
- if (originalDirectoryExists && originalCreateDirectory) {
115850
+ if (originalDirectoryExists) {
115834
115851
  host.directoryExists = function (directory) {
115835
115852
  var key = toPath(directory);
115836
115853
  var value = directoryExistsCache.get(key);
@@ -115840,11 +115857,13 @@ var ts;
115840
115857
  directoryExistsCache.set(key, !!newValue);
115841
115858
  return newValue;
115842
115859
  };
115843
- host.createDirectory = function (directory) {
115844
- var key = toPath(directory);
115845
- directoryExistsCache.delete(key);
115846
- originalCreateDirectory.call(host, directory);
115847
- };
115860
+ if (originalCreateDirectory) {
115861
+ host.createDirectory = function (directory) {
115862
+ var key = toPath(directory);
115863
+ directoryExistsCache.delete(key);
115864
+ originalCreateDirectory.call(host, directory);
115865
+ };
115866
+ }
115848
115867
  }
115849
115868
  return {
115850
115869
  originalReadFile: originalReadFile,
@@ -124089,7 +124108,6 @@ var ts;
124089
124108
  allProjectBuildPending: true,
124090
124109
  needsSummary: true,
124091
124110
  watchAllProjectsPending: watch,
124092
- currentInvalidatedProject: undefined,
124093
124111
  // Watch state
124094
124112
  watch: watch,
124095
124113
  allWatchedWildcardDirectories: new ts.Map(),
@@ -124322,7 +124340,6 @@ var ts;
124322
124340
  })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
124323
124341
  function doneInvalidatedProject(state, projectPath) {
124324
124342
  state.projectPendingBuild.delete(projectPath);
124325
- state.currentInvalidatedProject = undefined;
124326
124343
  return state.diagnostics.has(projectPath) ?
124327
124344
  ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
124328
124345
  ts.ExitStatus.Success;
@@ -124673,17 +124690,11 @@ var ts;
124673
124690
  !!ts.getConfigFileParsingDiagnostics(config).length ||
124674
124691
  !ts.isIncrementalCompilation(config.options);
124675
124692
  }
124676
- function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124693
+ function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
124677
124694
  if (!state.projectPendingBuild.size)
124678
124695
  return undefined;
124679
124696
  if (isCircularBuildOrder(buildOrder))
124680
124697
  return undefined;
124681
- if (state.currentInvalidatedProject) {
124682
- // Only if same buildOrder the currentInvalidated project can be sent again
124683
- return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
124684
- state.currentInvalidatedProject :
124685
- undefined;
124686
- }
124687
124698
  var options = state.options, projectPendingBuild = state.projectPendingBuild;
124688
124699
  for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
124689
124700
  var project = buildOrder[projectIndex];
@@ -124716,9 +124727,9 @@ var ts;
124716
124727
  watchPackageJsonFiles(state, project, projectPath, config);
124717
124728
  }
124718
124729
  var status = getUpToDateStatus(state, config, projectPath);
124719
- verboseReportProjectStatus(state, project, status);
124720
124730
  if (!options.force) {
124721
124731
  if (status.type === ts.UpToDateStatusType.UpToDate) {
124732
+ verboseReportProjectStatus(state, project, status);
124722
124733
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
124723
124734
  projectPendingBuild.delete(projectPath);
124724
124735
  // Up to date, skip
@@ -124730,10 +124741,18 @@ var ts;
124730
124741
  }
124731
124742
  if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
124732
124743
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
124733
- return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
124744
+ return {
124745
+ kind: InvalidatedProjectKind.UpdateOutputFileStamps,
124746
+ status: status,
124747
+ project: project,
124748
+ projectPath: projectPath,
124749
+ projectIndex: projectIndex,
124750
+ config: config
124751
+ };
124734
124752
  }
124735
124753
  }
124736
124754
  if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
124755
+ verboseReportProjectStatus(state, project, status);
124737
124756
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
124738
124757
  projectPendingBuild.delete(projectPath);
124739
124758
  if (options.verbose) {
@@ -124744,17 +124763,37 @@ var ts;
124744
124763
  continue;
124745
124764
  }
124746
124765
  if (status.type === ts.UpToDateStatusType.ContainerOnly) {
124766
+ verboseReportProjectStatus(state, project, status);
124747
124767
  reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
124748
124768
  projectPendingBuild.delete(projectPath);
124749
124769
  // Do nothing
124750
124770
  continue;
124751
124771
  }
124752
- return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
124753
- InvalidatedProjectKind.Build :
124754
- InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
124772
+ return {
124773
+ kind: needsBuild(state, status, config) ?
124774
+ InvalidatedProjectKind.Build :
124775
+ InvalidatedProjectKind.UpdateBundle,
124776
+ status: status,
124777
+ project: project,
124778
+ projectPath: projectPath,
124779
+ projectIndex: projectIndex,
124780
+ config: config,
124781
+ };
124755
124782
  }
124756
124783
  return undefined;
124757
124784
  }
124785
+ function createInvalidatedProjectWithInfo(state, info, buildOrder) {
124786
+ verboseReportProjectStatus(state, info.project, info.status);
124787
+ return info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps ?
124788
+ createBuildOrUpdateInvalidedProject(info.kind, state, info.project, info.projectPath, info.projectIndex, info.config, buildOrder) :
124789
+ createUpdateOutputFileStampsProject(state, info.project, info.projectPath, info.config, buildOrder);
124790
+ }
124791
+ function getNextInvalidatedProject(state, buildOrder, reportQueue) {
124792
+ var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
124793
+ if (!info)
124794
+ return info;
124795
+ return createInvalidatedProjectWithInfo(state, info, buildOrder);
124796
+ }
124758
124797
  function listEmittedFile(_a, proj, file) {
124759
124798
  var write = _a.write;
124760
124799
  if (write && proj.options.listEmittedFiles) {
@@ -125195,9 +125234,9 @@ var ts;
125195
125234
  function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
125196
125235
  state.reportFileChangeDetected = true;
125197
125236
  invalidateProject(state, resolvedPath, reloadLevel);
125198
- scheduleBuildInvalidatedProject(state);
125237
+ scheduleBuildInvalidatedProject(state, 250, /*changeDetected*/ true);
125199
125238
  }
125200
- function scheduleBuildInvalidatedProject(state) {
125239
+ function scheduleBuildInvalidatedProject(state, time, changeDetected) {
125201
125240
  var hostWithWatch = state.hostWithWatch;
125202
125241
  if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
125203
125242
  return;
@@ -125205,25 +125244,38 @@ var ts;
125205
125244
  if (state.timerToBuildInvalidatedProject) {
125206
125245
  hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
125207
125246
  }
125208
- state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
125247
+ state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
125209
125248
  }
125210
- function buildNextInvalidatedProject(state) {
125249
+ function buildNextInvalidatedProject(state, changeDetected) {
125211
125250
  state.timerToBuildInvalidatedProject = undefined;
125212
125251
  if (state.reportFileChangeDetected) {
125213
125252
  state.reportFileChangeDetected = false;
125214
125253
  state.projectErrorsReported.clear();
125215
125254
  reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
125216
125255
  }
125256
+ var projectsBuilt = 0;
125217
125257
  var buildOrder = getBuildOrder(state);
125218
125258
  var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
125219
125259
  if (invalidatedProject) {
125220
125260
  invalidatedProject.done();
125221
- if (state.projectPendingBuild.size) {
125222
- // Schedule next project for build
125223
- if (state.watch && !state.timerToBuildInvalidatedProject) {
125224
- scheduleBuildInvalidatedProject(state);
125261
+ projectsBuilt++;
125262
+ while (state.projectPendingBuild.size) {
125263
+ // If already scheduled, skip
125264
+ if (state.timerToBuildInvalidatedProject)
125265
+ return;
125266
+ // Before scheduling check if the next project needs build
125267
+ var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, /*reportQueue*/ false);
125268
+ if (!info)
125269
+ break; // Nothing to build any more
125270
+ if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps && (changeDetected || projectsBuilt === 5)) {
125271
+ // Schedule next project for build
125272
+ scheduleBuildInvalidatedProject(state, 100, /*changeDetected*/ false);
125273
+ return;
125225
125274
  }
125226
- return;
125275
+ var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
125276
+ project.done();
125277
+ if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
125278
+ projectsBuilt++;
125227
125279
  }
125228
125280
  }
125229
125281
  disableCache(state);
@@ -125327,8 +125379,6 @@ var ts;
125327
125379
  return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
125328
125380
  },
125329
125381
  invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
125330
- buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
125331
- getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
125332
125382
  close: function () { return stopWatching(state); },
125333
125383
  };
125334
125384
  }
@@ -127813,6 +127863,41 @@ var ts;
127813
127863
  return true;
127814
127864
  }
127815
127865
  ts.isTextWhiteSpaceLike = isTextWhiteSpaceLike;
127866
+ function getMappedLocation(location, sourceMapper, fileExists) {
127867
+ var mapsTo = sourceMapper.tryGetSourcePosition(location);
127868
+ return mapsTo && (!fileExists || fileExists(ts.normalizePath(mapsTo.fileName)) ? mapsTo : undefined);
127869
+ }
127870
+ ts.getMappedLocation = getMappedLocation;
127871
+ function getMappedDocumentSpan(documentSpan, sourceMapper, fileExists) {
127872
+ var fileName = documentSpan.fileName, textSpan = documentSpan.textSpan;
127873
+ var newPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start }, sourceMapper, fileExists);
127874
+ if (!newPosition)
127875
+ return undefined;
127876
+ var newEndPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start + textSpan.length }, sourceMapper, fileExists);
127877
+ var newLength = newEndPosition
127878
+ ? newEndPosition.pos - newPosition.pos
127879
+ : textSpan.length; // This shouldn't happen
127880
+ return {
127881
+ fileName: newPosition.fileName,
127882
+ textSpan: {
127883
+ start: newPosition.pos,
127884
+ length: newLength,
127885
+ },
127886
+ originalFileName: documentSpan.fileName,
127887
+ originalTextSpan: documentSpan.textSpan,
127888
+ contextSpan: getMappedContextSpan(documentSpan, sourceMapper, fileExists),
127889
+ originalContextSpan: documentSpan.contextSpan
127890
+ };
127891
+ }
127892
+ ts.getMappedDocumentSpan = getMappedDocumentSpan;
127893
+ function getMappedContextSpan(documentSpan, sourceMapper, fileExists) {
127894
+ var contextSpanStart = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start }, sourceMapper, fileExists);
127895
+ var contextSpanEnd = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length }, sourceMapper, fileExists);
127896
+ return contextSpanStart && contextSpanEnd ?
127897
+ { start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } :
127898
+ undefined;
127899
+ }
127900
+ ts.getMappedContextSpan = getMappedContextSpan;
127816
127901
  // #endregion
127817
127902
  // Display-part writer helpers
127818
127903
  // #region
@@ -131009,6 +131094,7 @@ var ts;
131009
131094
  * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
131010
131095
  */
131011
131096
  function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) {
131097
+ var _b;
131012
131098
  var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption;
131013
131099
  if (result === void 0) { result = []; }
131014
131100
  if (fragment === undefined) {
@@ -131026,9 +131112,26 @@ var ts;
131026
131112
  fragment = "." + ts.directorySeparator;
131027
131113
  }
131028
131114
  fragment = ts.ensureTrailingDirectorySeparator(fragment);
131029
- // const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); // TODO(rbuckton): should use resolvePaths
131030
131115
  var absolutePath = ts.resolvePath(scriptPath, fragment);
131031
131116
  var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath);
131117
+ // check for a version redirect
131118
+ var packageJsonPath = ts.findPackageJson(baseDirectory, host);
131119
+ if (packageJsonPath) {
131120
+ var packageJson = ts.readJson(packageJsonPath, host);
131121
+ var typesVersions = packageJson.typesVersions;
131122
+ if (typeof typesVersions === "object") {
131123
+ var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths;
131124
+ if (versionPaths) {
131125
+ var packageDirectory = ts.getDirectoryPath(packageJsonPath);
131126
+ var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
131127
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
131128
+ // A true result means one of the `versionPaths` was matched, which will block relative resolution
131129
+ // to files and folders from here. All reachable paths given the pattern match are already added.
131130
+ return result;
131131
+ }
131132
+ }
131133
+ }
131134
+ }
131032
131135
  var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
131033
131136
  if (!ts.tryDirectoryExists(host, baseDirectory))
131034
131137
  return result;
@@ -131070,48 +131173,62 @@ var ts;
131070
131173
  // If possible, get folder completion as well
131071
131174
  var directories = ts.tryGetDirectories(host, baseDirectory);
131072
131175
  if (directories) {
131073
- for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) {
131074
- var directory = directories_1[_b];
131176
+ for (var _c = 0, directories_1 = directories; _c < directories_1.length; _c++) {
131177
+ var directory = directories_1[_c];
131075
131178
  var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
131076
131179
  if (directoryName !== "@types") {
131077
131180
  result.push(directoryResult(directoryName));
131078
131181
  }
131079
131182
  }
131080
131183
  }
131081
- // check for a version redirect
131082
- var packageJsonPath = ts.findPackageJson(baseDirectory, host);
131083
- if (packageJsonPath) {
131084
- var packageJson = ts.readJson(packageJsonPath, host);
131085
- var typesVersions = packageJson.typesVersions;
131086
- if (typeof typesVersions === "object") {
131087
- var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions);
131088
- var versionPaths = versionResult && versionResult.paths;
131089
- var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length);
131090
- if (versionPaths) {
131091
- addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host);
131092
- }
131093
- }
131094
- }
131095
131184
  return result;
131096
131185
  }
131186
+ /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
131097
131187
  function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) {
131188
+ var _a;
131189
+ var pathResults = [];
131190
+ var matchedPathPrefixLength = -1;
131098
131191
  for (var path in paths) {
131099
131192
  if (!ts.hasProperty(paths, path))
131100
131193
  continue;
131101
131194
  var patterns = paths[path];
131102
131195
  if (patterns) {
131103
- var _loop_3 = function (name, kind, extension) {
131104
- // Path mappings may provide a duplicate way to get to something we've already added, so don't add again.
131105
- if (!result.some(function (entry) { return entry.name === name; })) {
131106
- result.push(nameAndKind(name, kind, extension));
131107
- }
131108
- };
131109
- for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) {
131110
- var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension;
131111
- _loop_3(name, kind, extension);
131196
+ var pathPattern = ts.tryParsePattern(path);
131197
+ if (!pathPattern)
131198
+ continue;
131199
+ var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
131200
+ var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
131201
+ if (isLongestMatch) {
131202
+ // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
131203
+ // for `import {} from "some-package/|"` with a typesVersions:
131204
+ // {
131205
+ // "bar/*": ["bar/*"], // <-- 1. We add 'bar', but 'bar/*' doesn't match yet.
131206
+ // "*": ["dist/*"], // <-- 2. We match here and add files from dist. 'bar' is still ok because it didn't come from a match.
131207
+ // "foo/*": ["foo/*"] // <-- 3. We matched '*' earlier and added results from dist, but if 'foo/*' also matched,
131208
+ // } results in dist would not be visible. 'bar' still stands because it didn't come from a match.
131209
+ // This is especially important if `dist/foo` is a folder, because if we fail to clear results
131210
+ // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
131211
+ // ./dist/foo and ./foo, when only the latter will actually be resolvable.
131212
+ // See pathCompletionsTypesVersionsWildcard6.ts.
131213
+ matchedPathPrefixLength = pathPattern.prefix.length;
131214
+ pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
131215
+ }
131216
+ if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
131217
+ pathResults.push({
131218
+ matchedPattern: isMatch,
131219
+ results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
131220
+ .map(function (_a) {
131221
+ var name = _a.name, kind = _a.kind, extension = _a.extension;
131222
+ return nameAndKind(name, kind, extension);
131223
+ }),
131224
+ });
131112
131225
  }
131113
131226
  }
131114
131227
  }
131228
+ var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
131229
+ var equateResults = function (a, b) { return equatePaths(a.name, b.name); };
131230
+ pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
131231
+ return matchedPathPrefixLength > -1;
131115
131232
  }
131116
131233
  /**
131117
131234
  * Check all of the declared modules and those in node modules. Possible sources of modules:
@@ -131143,7 +131260,7 @@ var ts;
131143
131260
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
131144
131261
  var foundGlobal = false;
131145
131262
  if (fragmentDirectory === undefined) {
131146
- var _loop_4 = function (moduleName) {
131263
+ var _loop_3 = function (moduleName) {
131147
131264
  if (!result.some(function (entry) { return entry.name === moduleName; })) {
131148
131265
  foundGlobal = true;
131149
131266
  result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
@@ -131151,7 +131268,7 @@ var ts;
131151
131268
  };
131152
131269
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
131153
131270
  var moduleName = _c[_b];
131154
- _loop_4(moduleName);
131271
+ _loop_3(moduleName);
131155
131272
  }
131156
131273
  }
131157
131274
  if (!foundGlobal) {
@@ -131231,11 +131348,16 @@ var ts;
131231
131348
  }
131232
131349
  var pathPrefix = path.slice(0, path.length - 1);
131233
131350
  var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
131234
- return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) {
131235
- return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host);
131236
- });
131351
+ if (remainingFragment === undefined) {
131352
+ var starIsFullPathComponent = path[path.length - 2] === "/";
131353
+ 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) {
131354
+ var name = _a.name, rest = __rest(_a, ["name"]);
131355
+ return (__assign({ name: pathPrefix + name }, rest));
131356
+ }); });
131357
+ }
131358
+ return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); });
131237
131359
  function justPathMappingName(name) {
131238
- return ts.startsWith(name, fragment) ? [directoryResult(name)] : ts.emptyArray;
131360
+ return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray;
131239
131361
  }
131240
131362
  }
131241
131363
  function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) {
@@ -134592,6 +134714,7 @@ var ts;
134592
134714
  return kind === 131 /* AsyncKeyword */
134593
134715
  || kind === 132 /* AwaitKeyword */
134594
134716
  || kind === 127 /* AsKeyword */
134717
+ || kind === 152 /* TypeKeyword */
134595
134718
  || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
134596
134719
  }
134597
134720
  function keywordForNode(node) {
@@ -136734,6 +136857,7 @@ var ts;
136734
136857
  var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined;
136735
136858
  return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; })));
136736
136859
  }
136860
+ FindAllReferences.isDeclarationOfSymbol = isDeclarationOfSymbol;
136737
136861
  /**
136738
136862
  * True if 'decl' provides a value, as in `function f() {}`;
136739
136863
  * false if 'decl' is just a location for a future write, as in 'let x;'
@@ -136940,7 +137064,7 @@ var ts;
136940
137064
  result = references;
136941
137065
  continue;
136942
137066
  }
136943
- var _loop_5 = function (entry) {
137067
+ var _loop_4 = function (entry) {
136944
137068
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
136945
137069
  result.push(entry);
136946
137070
  return "continue";
@@ -136972,7 +137096,7 @@ var ts;
136972
137096
  };
136973
137097
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
136974
137098
  var entry = references_2[_b];
136975
- _loop_5(entry);
137099
+ _loop_4(entry);
136976
137100
  }
136977
137101
  }
136978
137102
  return result;
@@ -139000,7 +139124,7 @@ var ts;
139000
139124
  }
139001
139125
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
139002
139126
  var allFiles = program.getSourceFiles();
139003
- var _loop_6 = function (sourceFile) {
139127
+ var _loop_5 = function (sourceFile) {
139004
139128
  var newFromOld = oldToNew(sourceFile.fileName);
139005
139129
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
139006
139130
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -139032,7 +139156,7 @@ var ts;
139032
139156
  };
139033
139157
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
139034
139158
  var sourceFile = allFiles_1[_i];
139035
- _loop_6(sourceFile);
139159
+ _loop_5(sourceFile);
139036
139160
  }
139037
139161
  }
139038
139162
  function combineNormal(pathA, pathB) {
@@ -140056,7 +140180,7 @@ var ts;
140056
140180
  if (!patternMatcher)
140057
140181
  return ts.emptyArray;
140058
140182
  var rawItems = [];
140059
- var _loop_7 = function (sourceFile) {
140183
+ var _loop_6 = function (sourceFile) {
140060
140184
  cancellationToken.throwIfCancellationRequested();
140061
140185
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
140062
140186
  return "continue";
@@ -140068,7 +140192,7 @@ var ts;
140068
140192
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
140069
140193
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
140070
140194
  var sourceFile = sourceFiles_4[_i];
140071
- _loop_7(sourceFile);
140195
+ _loop_6(sourceFile);
140072
140196
  }
140073
140197
  rawItems.sort(compareNavigateToItems);
140074
140198
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -142133,13 +142257,13 @@ var ts;
142133
142257
  // Assumes 'value' is already lowercase.
142134
142258
  function indexOfIgnoringCase(str, value) {
142135
142259
  var n = str.length - value.length;
142136
- var _loop_8 = function (start) {
142260
+ var _loop_7 = function (start) {
142137
142261
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
142138
142262
  return { value: start };
142139
142263
  }
142140
142264
  };
142141
142265
  for (var start = 0; start <= n; start++) {
142142
- var state_3 = _loop_8(start);
142266
+ var state_3 = _loop_7(start);
142143
142267
  if (typeof state_3 === "object")
142144
142268
  return state_3.value;
142145
142269
  }
@@ -143558,7 +143682,7 @@ var ts;
143558
143682
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
143559
143683
  }
143560
143684
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
143561
- var _loop_9 = function (n) {
143685
+ var _loop_8 = function (n) {
143562
143686
  // If the node is not a subspan of its parent, this is a big problem.
143563
143687
  // There have been crashes that might be caused by this violation.
143564
143688
  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); });
@@ -143568,7 +143692,7 @@ var ts;
143568
143692
  }
143569
143693
  };
143570
143694
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
143571
- var state_4 = _loop_9(n);
143695
+ var state_4 = _loop_8(n);
143572
143696
  if (typeof state_4 === "object")
143573
143697
  return state_4.value;
143574
143698
  }
@@ -145167,7 +145291,7 @@ var ts;
145167
145291
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
145168
145292
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
145169
145293
  options = ts.cloneCompilerOptions(options);
145170
- var _loop_10 = function (opt) {
145294
+ var _loop_9 = function (opt) {
145171
145295
  if (!ts.hasProperty(options, opt.name)) {
145172
145296
  return "continue";
145173
145297
  }
@@ -145186,7 +145310,7 @@ var ts;
145186
145310
  };
145187
145311
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
145188
145312
  var opt = commandLineOptionsStringToEnum_1[_i];
145189
- _loop_10(opt);
145313
+ _loop_9(opt);
145190
145314
  }
145191
145315
  return options;
145192
145316
  }
@@ -148934,7 +149058,7 @@ var ts;
148934
149058
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
148935
149059
  var _this = this;
148936
149060
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
148937
- var _loop_11 = function (sourceFile, node) {
149061
+ var _loop_10 = function (sourceFile, node) {
148938
149062
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
148939
149063
  if (ts.isArray(node)) {
148940
149064
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -148947,7 +149071,7 @@ var ts;
148947
149071
  var this_1 = this;
148948
149072
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
148949
149073
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
148950
- _loop_11(sourceFile, node);
149074
+ _loop_10(sourceFile, node);
148951
149075
  }
148952
149076
  deletedNodesInLists.forEach(function (node) {
148953
149077
  var sourceFile = node.getSourceFile();
@@ -149035,14 +149159,14 @@ var ts;
149035
149159
  // order changes by start position
149036
149160
  // 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.
149037
149161
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
149038
- var _loop_12 = function (i) {
149162
+ var _loop_11 = function (i) {
149039
149163
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
149040
149164
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
149041
149165
  });
149042
149166
  };
149043
149167
  // verify that change intervals do not overlap, except possibly at end points.
149044
149168
  for (var i = 0; i < normalized.length - 1; i++) {
149045
- _loop_12(i);
149169
+ _loop_11(i);
149046
149170
  }
149047
149171
  var textChanges = ts.mapDefined(normalized, function (c) {
149048
149172
  var span = ts.createTextSpanFromRange(c.range);
@@ -149951,7 +150075,7 @@ var ts;
149951
150075
  }
149952
150076
  var isCompleteFix = identifiers.isCompleteFix;
149953
150077
  var initializers;
149954
- var _loop_13 = function (identifier) {
150078
+ var _loop_12 = function (identifier) {
149955
150079
  var symbol = checker.getSymbolAtLocation(identifier);
149956
150080
  if (!symbol) {
149957
150081
  return "continue";
@@ -149984,7 +150108,7 @@ var ts;
149984
150108
  };
149985
150109
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
149986
150110
  var identifier = _a[_i];
149987
- _loop_13(identifier);
150111
+ _loop_12(identifier);
149988
150112
  }
149989
150113
  return initializers && {
149990
150114
  initializers: initializers,
@@ -150874,7 +150998,7 @@ var ts;
150874
150998
  functionToConvert.getStart(sourceFile);
150875
150999
  var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " };
150876
151000
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options);
150877
- var _loop_14 = function (returnStatement) {
151001
+ var _loop_13 = function (returnStatement) {
150878
151002
  ts.forEachChild(returnStatement, function visit(node) {
150879
151003
  if (ts.isCallExpression(node)) {
150880
151004
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -150896,7 +151020,7 @@ var ts;
150896
151020
  };
150897
151021
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
150898
151022
  var returnStatement = returnStatements_1[_i];
150899
- var state_5 = _loop_14(returnStatement);
151023
+ var state_5 = _loop_13(returnStatement);
150900
151024
  if (typeof state_5 === "object")
150901
151025
  return state_5.value;
150902
151026
  }
@@ -154144,7 +154268,7 @@ var ts;
154144
154268
  });
154145
154269
  typeDeclToMembers.forEach(function (infos, declaration) {
154146
154270
  var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
154147
- var _loop_15 = function (info) {
154271
+ var _loop_14 = function (info) {
154148
154272
  // If some superclass added this property, don't add it again.
154149
154273
  if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
154150
154274
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -154171,7 +154295,7 @@ var ts;
154171
154295
  };
154172
154296
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
154173
154297
  var info = infos_1[_i];
154174
- _loop_15(info);
154298
+ _loop_14(info);
154175
154299
  }
154176
154300
  });
154177
154301
  }));
@@ -156934,7 +157058,7 @@ var ts;
156934
157058
  function getSignatureFromCalls(calls) {
156935
157059
  var parameters = [];
156936
157060
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
156937
- var _loop_16 = function (i) {
157061
+ var _loop_15 = function (i) {
156938
157062
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
156939
157063
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
156940
157064
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -156943,7 +157067,7 @@ var ts;
156943
157067
  parameters.push(symbol);
156944
157068
  };
156945
157069
  for (var i = 0; i < length; i++) {
156946
- _loop_16(i);
157070
+ _loop_15(i);
156947
157071
  }
156948
157072
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
156949
157073
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -158916,7 +159040,7 @@ var ts;
158916
159040
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
158917
159041
  // 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 }`.
158918
159042
  var neededNamedImports = new ts.Set();
158919
- var _loop_17 = function (element) {
159043
+ var _loop_16 = function (element) {
158920
159044
  var propertyName = (element.propertyName || element.name).text;
158921
159045
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
158922
159046
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -158933,7 +159057,7 @@ var ts;
158933
159057
  };
158934
159058
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
158935
159059
  var element = _a[_i];
158936
- _loop_17(element);
159060
+ _loop_16(element);
158937
159061
  }
158938
159062
  changes.replaceNode(sourceFile, toConvert, shouldUseDefault
158939
159063
  ? ts.factory.createIdentifier(namespaceImportName)
@@ -160831,7 +160955,7 @@ var ts;
160831
160955
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
160832
160956
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
160833
160957
  }
160834
- var _loop_18 = function (i) {
160958
+ var _loop_17 = function (i) {
160835
160959
  var scopeUsages = usagesPerScope[i];
160836
160960
  // Special case: in the innermost scope, all usages are available.
160837
160961
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -160874,7 +160998,7 @@ var ts;
160874
160998
  }
160875
160999
  };
160876
161000
  for (var i = 0; i < scopes.length; i++) {
160877
- _loop_18(i);
161001
+ _loop_17(i);
160878
161002
  }
160879
161003
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
160880
161004
  function isInGenericContext(node) {
@@ -161577,10 +161701,10 @@ var ts;
161577
161701
  }
161578
161702
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
161579
161703
  var checker = program.getTypeChecker();
161580
- var _loop_19 = function (sourceFile) {
161704
+ var _loop_18 = function (sourceFile) {
161581
161705
  if (sourceFile === oldFile)
161582
161706
  return "continue";
161583
- var _loop_20 = function (statement) {
161707
+ var _loop_19 = function (statement) {
161584
161708
  forEachImportInStatement(statement, function (importNode) {
161585
161709
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
161586
161710
  return;
@@ -161602,12 +161726,12 @@ var ts;
161602
161726
  };
161603
161727
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
161604
161728
  var statement = _c[_b];
161605
- _loop_20(statement);
161729
+ _loop_19(statement);
161606
161730
  }
161607
161731
  };
161608
161732
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
161609
161733
  var sourceFile = _a[_i];
161610
- _loop_19(sourceFile);
161734
+ _loop_18(sourceFile);
161611
161735
  }
161612
161736
  }
161613
161737
  function getNamespaceLikeImport(node) {
@@ -162971,7 +163095,7 @@ var ts;
162971
163095
  var templateSpans = [];
162972
163096
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
162973
163097
  copyCommentFromStringLiterals(headIndexes, templateHead);
162974
- var _loop_21 = function (i) {
163098
+ var _loop_20 = function (i) {
162975
163099
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
162976
163100
  copyOperatorComments(i, currentNode);
162977
163101
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -163000,7 +163124,7 @@ var ts;
163000
163124
  };
163001
163125
  var out_i_1;
163002
163126
  for (var i = begin; i < nodes.length; i++) {
163003
- _loop_21(i);
163127
+ _loop_20(i);
163004
163128
  i = out_i_1;
163005
163129
  }
163006
163130
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -163836,7 +163960,7 @@ var ts;
163836
163960
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
163837
163961
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
163838
163962
  var seenSymbols_1 = new ts.Set();
163839
- var _loop_22 = function (declaration) {
163963
+ var _loop_21 = function (declaration) {
163840
163964
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
163841
163965
  var _a;
163842
163966
  if (!seenSymbols_1.has(symbol)) {
@@ -163853,7 +163977,7 @@ var ts;
163853
163977
  };
163854
163978
  for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
163855
163979
  var declaration = declarations_6[_i];
163856
- _loop_22(declaration);
163980
+ _loop_21(declaration);
163857
163981
  }
163858
163982
  }
163859
163983
  return tags;
@@ -163864,7 +163988,7 @@ var ts;
163864
163988
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
163865
163989
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
163866
163990
  var seenSymbols_2 = new ts.Set();
163867
- var _loop_23 = function (declaration) {
163991
+ var _loop_22 = function (declaration) {
163868
163992
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
163869
163993
  if (!seenSymbols_2.has(symbol)) {
163870
163994
  seenSymbols_2.add(symbol);
@@ -163880,7 +164004,7 @@ var ts;
163880
164004
  };
163881
164005
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
163882
164006
  var declaration = declarations_7[_i];
163883
- _loop_23(declaration);
164007
+ _loop_22(declaration);
163884
164008
  }
163885
164009
  }
163886
164010
  return doc;
@@ -164137,70 +164261,6 @@ var ts;
164137
164261
  return ts.codefix.getSupportedErrorCodes();
164138
164262
  }
164139
164263
  ts.getSupportedCodeFixes = getSupportedCodeFixes;
164140
- // Cache host information about script Should be refreshed
164141
- // at each language service public entry point, since we don't know when
164142
- // the set of scripts handled by the host changes.
164143
- var HostCache = /** @class */ (function () {
164144
- function HostCache(host, getCanonicalFileName) {
164145
- this.host = host;
164146
- // script id => script index
164147
- this.currentDirectory = host.getCurrentDirectory();
164148
- this.fileNameToEntry = new ts.Map();
164149
- // Initialize the list with the root file names
164150
- var rootFileNames = host.getScriptFileNames();
164151
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
164152
- for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
164153
- var fileName = rootFileNames_1[_i];
164154
- this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
164155
- }
164156
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
164157
- }
164158
- HostCache.prototype.createEntry = function (fileName, path) {
164159
- var entry;
164160
- var scriptSnapshot = this.host.getScriptSnapshot(fileName);
164161
- if (scriptSnapshot) {
164162
- entry = {
164163
- hostFileName: fileName,
164164
- version: this.host.getScriptVersion(fileName),
164165
- scriptSnapshot: scriptSnapshot,
164166
- scriptKind: ts.getScriptKind(fileName, this.host)
164167
- };
164168
- }
164169
- else {
164170
- entry = fileName;
164171
- }
164172
- this.fileNameToEntry.set(path, entry);
164173
- return entry;
164174
- };
164175
- HostCache.prototype.getEntryByPath = function (path) {
164176
- return this.fileNameToEntry.get(path);
164177
- };
164178
- HostCache.prototype.getHostFileInformation = function (path) {
164179
- var entry = this.fileNameToEntry.get(path);
164180
- return !ts.isString(entry) ? entry : undefined;
164181
- };
164182
- HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) {
164183
- var info = this.getEntryByPath(path) || this.createEntry(fileName, path);
164184
- return ts.isString(info) ? undefined : info; // TODO: GH#18217
164185
- };
164186
- HostCache.prototype.getRootFileNames = function () {
164187
- var names = [];
164188
- this.fileNameToEntry.forEach(function (entry) {
164189
- if (ts.isString(entry)) {
164190
- names.push(entry);
164191
- }
164192
- else {
164193
- names.push(entry.hostFileName);
164194
- }
164195
- });
164196
- return names;
164197
- };
164198
- HostCache.prototype.getScriptSnapshot = function (path) {
164199
- var file = this.getHostFileInformation(path);
164200
- return (file && file.scriptSnapshot); // TODO: GH#18217
164201
- };
164202
- return HostCache;
164203
- }());
164204
164264
  var SyntaxTreeCache = /** @class */ (function () {
164205
164265
  function SyntaxTreeCache(host) {
164206
164266
  this.host = host;
@@ -164462,32 +164522,13 @@ var ts;
164462
164522
  program = undefined; // TODO: GH#18217
164463
164523
  lastTypesRootVersion = typeRootsVersion;
164464
164524
  }
164525
+ var rootFileNames = host.getScriptFileNames();
164465
164526
  // Get a fresh cache of the host information
164466
- var hostCache = new HostCache(host, getCanonicalFileName);
164467
- var rootFileNames = hostCache.getRootFileNames();
164468
164527
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
164469
164528
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
164470
164529
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
164471
164530
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
164472
164531
  var parsedCommandLines;
164473
- var parseConfigHost = {
164474
- useCaseSensitiveFileNames: useCaseSensitiveFileNames,
164475
- fileExists: fileExists,
164476
- readFile: readFile,
164477
- readDirectory: readDirectory,
164478
- trace: ts.maybeBind(host, host.trace),
164479
- getCurrentDirectory: function () { return currentDirectory; },
164480
- onUnRecoverableConfigFileDiagnostic: ts.noop,
164481
- };
164482
- // If the program is already up-to-date, we can reuse it
164483
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
164484
- return;
164485
- }
164486
- // IMPORTANT - It is critical from this moment onward that we do not check
164487
- // cancellation tokens. We are about to mutate source files from a previous program
164488
- // instance. If we cancel midway through, we may end up in an inconsistent state where
164489
- // the program points to old source files that have been invalidated because of
164490
- // incremental parsing.
164491
164532
  // Now create a new compiler
164492
164533
  var compilerHost = {
164493
164534
  getSourceFile: getOrCreateSourceFile,
@@ -164499,8 +164540,8 @@ var ts;
164499
164540
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
164500
164541
  writeFile: ts.noop,
164501
164542
  getCurrentDirectory: function () { return currentDirectory; },
164502
- fileExists: fileExists,
164503
- readFile: readFile,
164543
+ fileExists: function (fileName) { return host.fileExists(fileName); },
164544
+ readFile: function (fileName) { return host.readFile && host.readFile(fileName); },
164504
164545
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
164505
164546
  realpath: ts.maybeBind(host, host.realpath),
164506
164547
  directoryExists: function (directoryName) {
@@ -164509,19 +164550,56 @@ var ts;
164509
164550
  getDirectories: function (path) {
164510
164551
  return host.getDirectories ? host.getDirectories(path) : [];
164511
164552
  },
164512
- readDirectory: readDirectory,
164553
+ readDirectory: function (path, extensions, exclude, include, depth) {
164554
+ ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
164555
+ return host.readDirectory(path, extensions, exclude, include, depth);
164556
+ },
164513
164557
  onReleaseOldSourceFile: onReleaseOldSourceFile,
164514
164558
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
164515
164559
  hasInvalidatedResolution: hasInvalidatedResolution,
164516
164560
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
164517
- trace: parseConfigHost.trace,
164561
+ trace: ts.maybeBind(host, host.trace),
164518
164562
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
164519
164563
  getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
164520
164564
  resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
164521
164565
  useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
164522
164566
  getParsedCommandLine: getParsedCommandLine,
164523
164567
  };
164568
+ var originalGetSourceFile = compilerHost.getSourceFile;
164569
+ var getSourceFileWithCache = ts.changeCompilerHostLikeToUseCache(compilerHost, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); }, function () {
164570
+ var args = [];
164571
+ for (var _i = 0; _i < arguments.length; _i++) {
164572
+ args[_i] = arguments[_i];
164573
+ }
164574
+ return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args, false));
164575
+ }).getSourceFileWithCache;
164576
+ compilerHost.getSourceFile = getSourceFileWithCache;
164524
164577
  (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost);
164578
+ var parseConfigHost = {
164579
+ useCaseSensitiveFileNames: useCaseSensitiveFileNames,
164580
+ fileExists: function (fileName) { return compilerHost.fileExists(fileName); },
164581
+ readFile: function (fileName) { return compilerHost.readFile(fileName); },
164582
+ readDirectory: function () {
164583
+ var _a;
164584
+ var args = [];
164585
+ for (var _i = 0; _i < arguments.length; _i++) {
164586
+ args[_i] = arguments[_i];
164587
+ }
164588
+ return (_a = compilerHost).readDirectory.apply(_a, args);
164589
+ },
164590
+ trace: compilerHost.trace,
164591
+ getCurrentDirectory: compilerHost.getCurrentDirectory,
164592
+ onUnRecoverableConfigFileDiagnostic: ts.noop,
164593
+ };
164594
+ // If the program is already up-to-date, we can reuse it
164595
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
164596
+ return;
164597
+ }
164598
+ // IMPORTANT - It is critical from this moment onward that we do not check
164599
+ // cancellation tokens. We are about to mutate source files from a previous program
164600
+ // instance. If we cancel midway through, we may end up in an inconsistent state where
164601
+ // the program points to old source files that have been invalidated because of
164602
+ // incremental parsing.
164525
164603
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
164526
164604
  var options = {
164527
164605
  rootNames: rootFileNames,
@@ -164531,9 +164609,9 @@ var ts;
164531
164609
  projectReferences: projectReferences
164532
164610
  };
164533
164611
  program = ts.createProgram(options);
164534
- // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
164535
- // It needs to be cleared to allow all collected snapshots to be released
164536
- hostCache = undefined;
164612
+ // 'getOrCreateSourceFile' depends on caching but should be used past this point.
164613
+ // After this point, the cache needs to be cleared to allow all collected snapshots to be released
164614
+ compilerHost = undefined;
164537
164615
  parsedCommandLines = undefined;
164538
164616
  // 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,
164539
164617
  // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during
@@ -164573,26 +164651,6 @@ var ts;
164573
164651
  onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
164574
164652
  }
164575
164653
  }
164576
- function fileExists(fileName) {
164577
- var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
164578
- var entry = hostCache && hostCache.getEntryByPath(path);
164579
- return entry ?
164580
- !ts.isString(entry) :
164581
- (!!host.fileExists && host.fileExists(fileName));
164582
- }
164583
- function readFile(fileName) {
164584
- // stub missing host functionality
164585
- var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
164586
- var entry = hostCache && hostCache.getEntryByPath(path);
164587
- if (entry) {
164588
- return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot);
164589
- }
164590
- return host.readFile && host.readFile(fileName);
164591
- }
164592
- function readDirectory(path, extensions, exclude, include, depth) {
164593
- ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
164594
- return host.readDirectory(path, extensions, exclude, include, depth);
164595
- }
164596
164654
  // Release any files we have acquired in the old program but are
164597
164655
  // not part of the new program.
164598
164656
  function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
@@ -164603,14 +164661,16 @@ var ts;
164603
164661
  return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile);
164604
164662
  }
164605
164663
  function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) {
164606
- ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
164664
+ ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
164607
164665
  // The program is asking for this file, check first if the host can locate it.
164608
164666
  // If the host can not locate the file, then it does not exist. return undefined
164609
164667
  // to the program to allow reporting of errors for missing files.
164610
- var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path);
164611
- if (!hostFileInformation) {
164668
+ var scriptSnapshot = host.getScriptSnapshot(fileName);
164669
+ if (!scriptSnapshot) {
164612
164670
  return undefined;
164613
164671
  }
164672
+ var scriptKind = ts.getScriptKind(fileName, host);
164673
+ var scriptVersion = host.getScriptVersion(fileName);
164614
164674
  // Check if the language version has changed since we last created a program; if they are the same,
164615
164675
  // it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile
164616
164676
  // can not be reused. we have to dump all syntax trees and create new ones.
@@ -164642,8 +164702,8 @@ var ts;
164642
164702
  // We do not support the scenario where a host can modify a registered
164643
164703
  // file's script kind, i.e. in one project some file is treated as ".ts"
164644
164704
  // and in another as ".js"
164645
- if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
164646
- return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
164705
+ if (scriptKind === oldSourceFile.scriptKind) {
164706
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
164647
164707
  }
164648
164708
  else {
164649
164709
  // Release old source file and fall through to aquire new file with new script kind
@@ -164653,7 +164713,7 @@ var ts;
164653
164713
  // We didn't already have the file. Fall through and acquire it from the registry.
164654
164714
  }
164655
164715
  // Could not find this file in the old program, create a new SourceFile for it.
164656
- return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
164716
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
164657
164717
  }
164658
164718
  }
164659
164719
  // TODO: GH#18217 frequently asserted as defined
@@ -164669,6 +164729,61 @@ var ts;
164669
164729
  var _a;
164670
164730
  return (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host);
164671
164731
  }
164732
+ function updateIsDefinitionOfReferencedSymbols(referencedSymbols, knownSymbolSpans) {
164733
+ var checker = program.getTypeChecker();
164734
+ var symbol = getSymbolForProgram();
164735
+ if (!symbol)
164736
+ return false;
164737
+ for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) {
164738
+ var referencedSymbol = referencedSymbols_1[_i];
164739
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
164740
+ var ref = _b[_a];
164741
+ var refNode = getNodeForSpan(ref);
164742
+ ts.Debug.assertIsDefined(refNode);
164743
+ if (knownSymbolSpans.has(ref) || ts.FindAllReferences.isDeclarationOfSymbol(refNode, symbol)) {
164744
+ knownSymbolSpans.add(ref);
164745
+ ref.isDefinition = true;
164746
+ var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
164747
+ if (mappedSpan) {
164748
+ knownSymbolSpans.add(mappedSpan);
164749
+ }
164750
+ }
164751
+ else {
164752
+ ref.isDefinition = false;
164753
+ }
164754
+ }
164755
+ }
164756
+ return true;
164757
+ function getSymbolForProgram() {
164758
+ for (var _i = 0, referencedSymbols_2 = referencedSymbols; _i < referencedSymbols_2.length; _i++) {
164759
+ var referencedSymbol = referencedSymbols_2[_i];
164760
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
164761
+ var ref = _b[_a];
164762
+ if (knownSymbolSpans.has(ref)) {
164763
+ var refNode = getNodeForSpan(ref);
164764
+ ts.Debug.assertIsDefined(refNode);
164765
+ return checker.getSymbolAtLocation(refNode);
164766
+ }
164767
+ var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
164768
+ if (mappedSpan && knownSymbolSpans.has(mappedSpan)) {
164769
+ var refNode = getNodeForSpan(mappedSpan);
164770
+ if (refNode) {
164771
+ return checker.getSymbolAtLocation(refNode);
164772
+ }
164773
+ }
164774
+ }
164775
+ }
164776
+ return undefined;
164777
+ }
164778
+ function getNodeForSpan(docSpan) {
164779
+ var sourceFile = program.getSourceFile(docSpan.fileName);
164780
+ if (!sourceFile)
164781
+ return undefined;
164782
+ var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start);
164783
+ var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ });
164784
+ return adjustedNode;
164785
+ }
164786
+ }
164672
164787
  function cleanupSemanticCache() {
164673
164788
  program = undefined; // TODO: GH#18217
164674
164789
  }
@@ -165595,6 +165710,7 @@ var ts;
165595
165710
  getNonBoundSourceFile: getNonBoundSourceFile,
165596
165711
  getProgram: getProgram,
165597
165712
  getAutoImportProvider: getAutoImportProvider,
165713
+ updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
165598
165714
  getApplicableRefactors: getApplicableRefactors,
165599
165715
  getEditsForRefactor: getEditsForRefactor,
165600
165716
  toLineColumnOffset: toLineColumnOffset,
@@ -174735,66 +174851,142 @@ var ts;
174735
174851
  return textSpan.start + 100003 * textSpan.length;
174736
174852
  }, ts.documentSpansEqual);
174737
174853
  }
174738
- function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, findInStrings, findInComments, _a) {
174854
+ function getRenameLocationsWorker(projects, defaultProject, initialLocation, findInStrings, findInComments, _a) {
174739
174855
  var providePrefixAndSuffixTextForRename = _a.providePrefixAndSuffixTextForRename;
174740
- var outputs = [];
174856
+ var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174857
+ /*isForRename*/ true, function (project, position) { return project.getLanguageService().findRenameLocations(position.fileName, position.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }, function (renameLocation, cb) { return cb(documentSpanLocation(renameLocation)); });
174858
+ // No filtering or dedup'ing is required if there's exactly one project
174859
+ if (ts.isArray(perProjectResults)) {
174860
+ return perProjectResults;
174861
+ }
174862
+ var results = [];
174741
174863
  var seen = createDocumentSpanSet();
174742
- combineProjectOutputWorker(projects, defaultProject, initialLocation,
174743
- /*isForRename*/ true, function (project, location, tryAddToTodo) {
174744
- var projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename);
174745
- if (projectOutputs) {
174746
- for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) {
174747
- var output = projectOutputs_1[_i];
174748
- if (!seen.has(output) && !tryAddToTodo(project, documentSpanLocation(output))) {
174749
- seen.add(output);
174750
- outputs.push(output);
174751
- }
174864
+ perProjectResults.forEach(function (projectResults, project) {
174865
+ for (var _i = 0, projectResults_1 = projectResults; _i < projectResults_1.length; _i++) {
174866
+ var result = projectResults_1[_i];
174867
+ // If there's a mapped location, it'll appear in the results for another project
174868
+ if (!seen.has(result) && !getMappedLocationForProject(documentSpanLocation(result), project)) {
174869
+ results.push(result);
174870
+ seen.add(result);
174752
174871
  }
174753
174872
  }
174754
174873
  });
174755
- return outputs;
174874
+ return results;
174756
174875
  }
174757
174876
  function getDefinitionLocation(defaultProject, initialLocation, isForRename) {
174758
- var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, isForRename);
174877
+ var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
174759
174878
  var info = infos && ts.firstOrUndefined(infos);
174760
174879
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
174761
174880
  }
174762
- function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) {
174763
- var outputs = [];
174764
- combineProjectOutputWorker(projects, defaultProject, initialLocation,
174765
- /*isForRename*/ false, function (project, location, getMappedLocation) {
174766
- var _a, _b;
174767
- logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
174768
- var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
174769
- if (projectOutputs) {
174770
- var clearIsDefinition = ((_b = (_a = projectOutputs[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined;
174771
- var _loop_9 = function (referencedSymbol) {
174772
- var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
174773
- var definition = mappedDefinitionFile === undefined ?
174774
- referencedSymbol.definition : __assign(__assign({}, referencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, referencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(referencedSymbol.definition, project) });
174775
- var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); });
174776
- if (!symbolToAddTo) {
174777
- symbolToAddTo = { definition: definition, references: [] };
174778
- outputs.push(symbolToAddTo);
174779
- }
174780
- for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
174781
- var ref = _d[_c];
174782
- // If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
174783
- if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
174784
- if (clearIsDefinition) {
174785
- delete ref.isDefinition;
174786
- }
174787
- symbolToAddTo.references.push(ref);
174788
- }
174881
+ function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
174882
+ var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174883
+ /*isForRename*/ false, function (project, position) {
174884
+ logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
174885
+ return project.getLanguageService().findReferences(position.fileName, position.pos);
174886
+ }, function (referencedSymbol, cb) {
174887
+ cb(documentSpanLocation(referencedSymbol.definition));
174888
+ for (var _i = 0, _a = referencedSymbol.references; _i < _a.length; _i++) {
174889
+ var ref = _a[_i];
174890
+ cb(documentSpanLocation(ref));
174891
+ }
174892
+ });
174893
+ // No re-mapping or isDefinition updatses are required if there's exactly one project
174894
+ if (ts.isArray(perProjectResults)) {
174895
+ return perProjectResults;
174896
+ }
174897
+ // `isDefinition` is only (definitely) correct in `defaultProject` because we might
174898
+ // have started the other project searches from related symbols. Propagate the
174899
+ // correct results to all other projects.
174900
+ var defaultProjectResults = perProjectResults.get(defaultProject);
174901
+ if (defaultProjectResults[0].references[0].isDefinition === undefined) {
174902
+ // Clear all isDefinition properties
174903
+ perProjectResults.forEach(function (projectResults) {
174904
+ for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
174905
+ var referencedSymbol = projectResults_2[_i];
174906
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174907
+ var ref = _b[_a];
174908
+ delete ref.isDefinition;
174909
+ }
174910
+ }
174911
+ });
174912
+ }
174913
+ else {
174914
+ // Correct isDefinition properties from projects other than defaultProject
174915
+ var knownSymbolSpans_1 = createDocumentSpanSet();
174916
+ for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
174917
+ var referencedSymbol = defaultProjectResults_1[_i];
174918
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174919
+ var ref = _b[_a];
174920
+ if (ref.isDefinition) {
174921
+ knownSymbolSpans_1.add(ref);
174922
+ // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
174923
+ break;
174924
+ }
174925
+ }
174926
+ }
174927
+ var updatedProjects_1 = new ts.Set();
174928
+ var _loop_9 = function () {
174929
+ var progress = false;
174930
+ perProjectResults.forEach(function (referencedSymbols, project) {
174931
+ if (updatedProjects_1.has(project))
174932
+ return;
174933
+ var updated = project.getLanguageService().updateIsDefinitionOfReferencedSymbols(referencedSymbols, knownSymbolSpans_1);
174934
+ if (updated) {
174935
+ updatedProjects_1.add(project);
174936
+ progress = true;
174937
+ }
174938
+ });
174939
+ if (!progress)
174940
+ return "break";
174941
+ };
174942
+ while (true) {
174943
+ var state_2 = _loop_9();
174944
+ if (state_2 === "break")
174945
+ break;
174946
+ }
174947
+ perProjectResults.forEach(function (referencedSymbols, project) {
174948
+ if (updatedProjects_1.has(project))
174949
+ return;
174950
+ for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) {
174951
+ var referencedSymbol = referencedSymbols_1[_i];
174952
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174953
+ var ref = _b[_a];
174954
+ ref.isDefinition = false;
174789
174955
  }
174790
- };
174791
- for (var _i = 0, projectOutputs_2 = projectOutputs; _i < projectOutputs_2.length; _i++) {
174792
- var referencedSymbol = projectOutputs_2[_i];
174793
- _loop_9(referencedSymbol);
174794
174956
  }
174957
+ });
174958
+ }
174959
+ // We need to de-duplicate and aggregate the results by choosing an authoritative version
174960
+ // of each definition and merging references from all the projects where they appear.
174961
+ var results = [];
174962
+ var seenRefs = createDocumentSpanSet(); // It doesn't make sense to have a reference in two definition lists, so we de-dup globally
174963
+ // TODO: We might end up with a more logical allocation of refs to defs if we pre-sorted the defs by descending ref-count.
174964
+ // Otherwise, it just ends up attached to the first corresponding def we happen to process. The others may or may not be
174965
+ // dropped later when we check for defs with ref-count 0.
174966
+ perProjectResults.forEach(function (projectResults, project) {
174967
+ var _loop_10 = function (referencedSymbol) {
174968
+ var mappedDefinitionFile = getMappedLocationForProject(documentSpanLocation(referencedSymbol.definition), project);
174969
+ var definition = mappedDefinitionFile === undefined ?
174970
+ referencedSymbol.definition : __assign(__assign({}, referencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, referencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpanForProject(referencedSymbol.definition, project) });
174971
+ var symbolToAddTo = ts.find(results, function (o) { return ts.documentSpansEqual(o.definition, definition); });
174972
+ if (!symbolToAddTo) {
174973
+ symbolToAddTo = { definition: definition, references: [] };
174974
+ results.push(symbolToAddTo);
174975
+ }
174976
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174977
+ var ref = _b[_a];
174978
+ if (!seenRefs.has(ref) && !getMappedLocationForProject(documentSpanLocation(ref), project)) {
174979
+ seenRefs.add(ref);
174980
+ symbolToAddTo.references.push(ref);
174981
+ }
174982
+ }
174983
+ };
174984
+ for (var _i = 0, projectResults_3 = projectResults; _i < projectResults_3.length; _i++) {
174985
+ var referencedSymbol = projectResults_3[_i];
174986
+ _loop_10(referencedSymbol);
174795
174987
  }
174796
174988
  });
174797
- return outputs.filter(function (o) { return o.references.length !== 0; });
174989
+ return results.filter(function (o) { return o.references.length !== 0; });
174798
174990
  }
174799
174991
  function forEachProjectInProjects(projects, path, cb) {
174800
174992
  for (var _i = 0, _a = ts.isArray(projects) ? projects : projects.projects; _i < _a.length; _i++) {
@@ -174810,40 +175002,117 @@ var ts;
174810
175002
  });
174811
175003
  }
174812
175004
  }
174813
- function combineProjectOutputWorker(projects, defaultProject, initialLocation, isForRename, cb) {
174814
- var projectService = defaultProject.projectService;
174815
- var toDo;
174816
- var seenProjects = new ts.Set();
174817
- forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, function (project, path) {
174818
- // TLocation should be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid.
174819
- var location = (initialLocation ? { fileName: path, pos: initialLocation.pos } : undefined);
174820
- toDo = callbackProjectAndLocation(project, location, projectService, toDo, seenProjects, cb);
175005
+ /**
175006
+ * @param projects Projects initially known to contain {@link initialLocation}
175007
+ * @param defaultProject The default project containing {@link initialLocation}
175008
+ * @param initialLocation Where the search operation was triggered
175009
+ * @param getResultsForPosition This is where you plug in `findReferences`, `renameLocation`, etc
175010
+ * @param forPositionInResult Given an item returned by {@link getResultsForPosition} enumerate the positions referred to by that result
175011
+ * @returns In the common case where there's only one project, returns an array of results from {@link getResultsForPosition}.
175012
+ * If multiple projects were searched - even if they didn't return results - the result will be a map from project to per-project results.
175013
+ */
175014
+ function getPerProjectReferences(projects, defaultProject, initialLocation, isForRename, getResultsForPosition, forPositionInResult) {
175015
+ // If `getResultsForPosition` returns results for a project, they go in here
175016
+ var resultsMap = new ts.Map();
175017
+ var queue = [];
175018
+ // In order to get accurate isDefinition values for `defaultProject`,
175019
+ // we need to ensure that it is searched from `initialLocation`.
175020
+ // The easiest way to do this is to search it first.
175021
+ queue.push({ project: defaultProject, location: initialLocation });
175022
+ // This will queue `defaultProject` a second time, but it will be dropped
175023
+ // as a dup when it is dequeued.
175024
+ forEachProjectInProjects(projects, initialLocation.fileName, function (project, path) {
175025
+ var location = { fileName: path, pos: initialLocation.pos };
175026
+ queue.push({ project: project, location: location });
174821
175027
  });
174822
- // After initial references are collected, go over every other project and see if it has a reference for the symbol definition.
174823
- if (initialLocation) {
174824
- var defaultDefinition_1 = getDefinitionLocation(defaultProject, initialLocation, isForRename);
174825
- if (defaultDefinition_1) {
174826
- var getGeneratedDefinition_1 = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition_1.fileName) ?
174827
- defaultDefinition_1 :
174828
- defaultProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(defaultDefinition_1); });
174829
- var getSourceDefinition_1 = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition_1.fileName) ?
174830
- defaultDefinition_1 :
174831
- defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition_1); });
174832
- projectService.loadAncestorProjectTree(seenProjects);
175028
+ var projectService = defaultProject.projectService;
175029
+ var cancellationToken = defaultProject.getCancellationToken();
175030
+ var defaultDefinition = getDefinitionLocation(defaultProject, initialLocation, isForRename);
175031
+ // Don't call these unless !!defaultDefinition
175032
+ var getGeneratedDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
175033
+ defaultDefinition :
175034
+ defaultProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(defaultDefinition); });
175035
+ var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
175036
+ defaultDefinition :
175037
+ defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
175038
+ // Track which projects we have already searched so that we don't repeat searches.
175039
+ // We store the project key, rather than the project, because that's what `loadAncestorProjectTree` wants.
175040
+ // (For that same reason, we don't use `resultsMap` for this check.)
175041
+ var searchedProjects = new ts.Set();
175042
+ onCancellation: while (queue.length) {
175043
+ while (queue.length) {
175044
+ if (cancellationToken.isCancellationRequested())
175045
+ break onCancellation;
175046
+ var _a = queue.shift(), project = _a.project, location = _a.location;
175047
+ if (isLocationProjectReferenceRedirect(project, location))
175048
+ continue;
175049
+ if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
175050
+ continue;
175051
+ var projectResults = searchPosition(project, location);
175052
+ if (projectResults) {
175053
+ resultsMap.set(project, projectResults);
175054
+ }
175055
+ }
175056
+ // At this point, we know about all projects passed in as arguments and any projects in which
175057
+ // `getResultsForPosition` has returned results. We expand that set to include any projects
175058
+ // downstream from any of these and then queue new initial-position searches for any new project
175059
+ // containing `initialLocation`.
175060
+ if (defaultDefinition) {
175061
+ // This seems to mean "load all projects downstream from any member of `seenProjects`".
175062
+ projectService.loadAncestorProjectTree(searchedProjects);
174833
175063
  projectService.forEachEnabledProject(function (project) {
174834
- if (!addToSeen(seenProjects, project))
174835
- return;
174836
- var definition = mapDefinitionInProject(defaultDefinition_1, project, getGeneratedDefinition_1, getSourceDefinition_1);
174837
- if (definition) {
174838
- toDo = callbackProjectAndLocation(project, definition, projectService, toDo, seenProjects, cb);
175064
+ if (cancellationToken.isCancellationRequested())
175065
+ return; // There's no mechanism for skipping the remaining projects
175066
+ if (searchedProjects.has(getProjectKey(project)))
175067
+ return; // Can loop forever without this (enqueue here, dequeue above, repeat)
175068
+ var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
175069
+ if (location) {
175070
+ queue.push({ project: project, location: location });
174839
175071
  }
174840
175072
  });
174841
175073
  }
174842
175074
  }
174843
- while (toDo && toDo.length) {
174844
- var next = toDo.pop();
174845
- ts.Debug.assertIsDefined(next);
174846
- toDo = callbackProjectAndLocation(next.project, next.location, projectService, toDo, seenProjects, cb);
175075
+ // In the common case where there's only one project, return a simpler result to make
175076
+ // it easier for the caller to skip post-processing.
175077
+ if (searchedProjects.size === 1) {
175078
+ var it = resultsMap.values().next();
175079
+ ts.Debug.assert(!it.done);
175080
+ return it.value;
175081
+ }
175082
+ return resultsMap;
175083
+ // May enqueue to otherPositionQueue
175084
+ function searchPosition(project, location) {
175085
+ var projectResults = getResultsForPosition(project, location);
175086
+ if (!projectResults)
175087
+ return undefined;
175088
+ for (var _i = 0, projectResults_4 = projectResults; _i < projectResults_4.length; _i++) {
175089
+ var result = projectResults_4[_i];
175090
+ forPositionInResult(result, function (position) {
175091
+ // This may trigger a search for a tsconfig, but there are several layers of caching that make it inexpensive
175092
+ var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, position);
175093
+ if (!originalLocation)
175094
+ return;
175095
+ var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
175096
+ for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
175097
+ var project_1 = _a[_i];
175098
+ if (!project_1.isOrphan()) {
175099
+ queue.push({ project: project_1, location: originalLocation });
175100
+ }
175101
+ }
175102
+ var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo);
175103
+ if (symlinkedProjectsMap) {
175104
+ symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
175105
+ for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
175106
+ var symlinkedProject = symlinkedProjects_2[_i];
175107
+ if (!symlinkedProject.isOrphan()) {
175108
+ queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
175109
+ }
175110
+ }
175111
+ });
175112
+ }
175113
+ });
175114
+ }
175115
+ return projectResults;
174847
175116
  }
174848
175117
  }
174849
175118
  function mapDefinitionInProject(definition, project, getGeneratedDefinition, getSourceDefinition) {
@@ -174874,43 +175143,6 @@ var ts;
174874
175143
  sourceFile.resolvedPath !== sourceFile.path &&
174875
175144
  sourceFile.resolvedPath !== project.toPath(location.fileName);
174876
175145
  }
174877
- function callbackProjectAndLocation(project, location, projectService, toDo, seenProjects, cb) {
174878
- if (project.getCancellationToken().isCancellationRequested())
174879
- return undefined; // Skip rest of toDo if cancelled
174880
- // If this is not the file we were actually looking, return rest of the toDo
174881
- if (isLocationProjectReferenceRedirect(project, location))
174882
- return toDo;
174883
- cb(project, location, function (innerProject, location) {
174884
- addToSeen(seenProjects, project);
174885
- var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(innerProject, location);
174886
- if (!originalLocation)
174887
- return undefined;
174888
- var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
174889
- toDo = toDo || [];
174890
- for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
174891
- var project_1 = _a[_i];
174892
- addToTodo(project_1, originalLocation, toDo, seenProjects);
174893
- }
174894
- var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo);
174895
- if (symlinkedProjectsMap) {
174896
- symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
174897
- for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
174898
- var symlinkedProject = symlinkedProjects_2[_i];
174899
- addToTodo(symlinkedProject, { fileName: symlinkedPath, pos: originalLocation.pos }, toDo, seenProjects);
174900
- }
174901
- });
174902
- }
174903
- return originalLocation === location ? undefined : originalLocation;
174904
- });
174905
- return toDo;
174906
- }
174907
- function addToTodo(project, location, toDo, seenProjects) {
174908
- if (!project.isOrphan() && addToSeen(seenProjects, project))
174909
- toDo.push({ project: project, location: location });
174910
- }
174911
- function addToSeen(seenProjects, project) {
174912
- return ts.tryAddToSet(seenProjects, getProjectKey(project));
174913
- }
174914
175146
  function getProjectKey(project) {
174915
175147
  return server.isConfiguredProject(project) ? project.canonicalConfigFilePath : project.getProjectName();
174916
175148
  }
@@ -174918,32 +175150,14 @@ var ts;
174918
175150
  var fileName = _a.fileName, textSpan = _a.textSpan;
174919
175151
  return { fileName: fileName, pos: textSpan.start };
174920
175152
  }
174921
- function getMappedLocation(location, project) {
174922
- var mapsTo = project.getSourceMapper().tryGetSourcePosition(location);
174923
- return mapsTo && project.projectService.fileExists(server.toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined;
175153
+ function getMappedLocationForProject(location, project) {
175154
+ return ts.getMappedLocation(location, project.getSourceMapper(), function (p) { return project.projectService.fileExists(p); });
174924
175155
  }
174925
- function getMappedDocumentSpan(documentSpan, project) {
174926
- var newPosition = getMappedLocation(documentSpanLocation(documentSpan), project);
174927
- if (!newPosition)
174928
- return undefined;
174929
- return {
174930
- fileName: newPosition.fileName,
174931
- textSpan: {
174932
- start: newPosition.pos,
174933
- length: documentSpan.textSpan.length
174934
- },
174935
- originalFileName: documentSpan.fileName,
174936
- originalTextSpan: documentSpan.textSpan,
174937
- contextSpan: getMappedContextSpan(documentSpan, project),
174938
- originalContextSpan: documentSpan.contextSpan
174939
- };
175156
+ function getMappedDocumentSpanForProject(documentSpan, project) {
175157
+ return ts.getMappedDocumentSpan(documentSpan, project.getSourceMapper(), function (p) { return project.projectService.fileExists(p); });
174940
175158
  }
174941
- function getMappedContextSpan(documentSpan, project) {
174942
- var contextSpanStart = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start }, project);
174943
- var contextSpanEnd = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length }, project);
174944
- return contextSpanStart && contextSpanEnd ?
174945
- { start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } :
174946
- undefined;
175159
+ function getMappedContextSpanForProject(documentSpan, project) {
175160
+ return ts.getMappedContextSpan(documentSpan, project.getSourceMapper(), function (p) { return project.projectService.fileExists(p); });
174947
175161
  }
174948
175162
  var invalidPartialSemanticModeCommands = [
174949
175163
  server.CommandNames.OpenExternalProject,
@@ -175836,7 +176050,7 @@ var ts;
175836
176050
  };
175837
176051
  Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
175838
176052
  return definitions.map(function (info) {
175839
- var newDocumentSpan = getMappedDocumentSpan(info, project);
176053
+ var newDocumentSpan = getMappedDocumentSpanForProject(info, project);
175840
176054
  return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
175841
176055
  });
175842
176056
  };
@@ -176081,7 +176295,7 @@ var ts;
176081
176295
  };
176082
176296
  Session.prototype.mapImplementationLocations = function (implementations, project) {
176083
176297
  return implementations.map(function (info) {
176084
- var newDocumentSpan = getMappedDocumentSpan(info, project);
176298
+ var newDocumentSpan = getMappedDocumentSpanForProject(info, project);
176085
176299
  return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { kind: info.kind, displayParts: info.displayParts });
176086
176300
  });
176087
176301
  };
@@ -176238,7 +176452,7 @@ var ts;
176238
176452
  var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
176239
176453
  if (!renameInfo.canRename)
176240
176454
  return simplifiedResult ? { info: renameInfo, locs: [] } : [];
176241
- var locations = combineProjectOutputForRenameLocations(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
176455
+ var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
176242
176456
  if (!simplifiedResult)
176243
176457
  return locations;
176244
176458
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
@@ -176270,7 +176484,7 @@ var ts;
176270
176484
  var file = server.toNormalizedPath(args.file);
176271
176485
  var projects = this.getProjects(args);
176272
176486
  var position = this.getPositionInFile(args, file);
176273
- var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
176487
+ var references = getReferencesWorker(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
176274
176488
  if (!simplifiedResult)
176275
176489
  return references;
176276
176490
  var defaultProject = this.getDefaultProject(args);
@@ -176296,8 +176510,8 @@ var ts;
176296
176510
  return;
176297
176511
  var projectOutputs = project.getLanguageService().getFileReferences(fileName);
176298
176512
  if (projectOutputs) {
176299
- for (var _i = 0, projectOutputs_3 = projectOutputs; _i < projectOutputs_3.length; _i++) {
176300
- var referenceEntry = projectOutputs_3[_i];
176513
+ for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) {
176514
+ var referenceEntry = projectOutputs_1[_i];
176301
176515
  if (!seen.has(referenceEntry)) {
176302
176516
  references.push(referenceEntry);
176303
176517
  seen.add(referenceEntry);
@@ -176762,7 +176976,8 @@ var ts;
176762
176976
  // `name` is a very cheap hash function, but we could incorporate other properties to reduce collisions.
176763
176977
  var seenItems = new ts.Map(); // name to items with that name
176764
176978
  if (!args.file && !projectFileName) {
176765
- // VS Code's `Go to symbol in workspaces` sends request like this
176979
+ // VS Code's `Go to symbol in workspaces` sends request like this by default.
176980
+ // There's a setting to have it send a file name (reverting to older behavior).
176766
176981
  // TODO (https://github.com/microsoft/TypeScript/issues/47839)
176767
176982
  // This appears to have been intended to search all projects but, in practice, it seems to only search
176768
176983
  // those that are downstream from already-loaded projects.
@@ -176783,7 +176998,7 @@ var ts;
176783
176998
  // Mutates `outputs`
176784
176999
  function addItemsForProject(project) {
176785
177000
  var projectItems = project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*filename*/ undefined, /*excludeDts*/ project.isNonTsProject());
176786
- var unseenItems = ts.filter(projectItems, function (item) { return tryAddSeenItem(item) && !getMappedLocation(documentSpanLocation(item), project); });
177001
+ var unseenItems = ts.filter(projectItems, function (item) { return tryAddSeenItem(item) && !getMappedLocationForProject(documentSpanLocation(item), project); });
176787
177002
  if (unseenItems.length) {
176788
177003
  outputs.push({ project: project, navigateToItems: unseenItems });
176789
177004
  }