typescript 4.8.0-dev.20220516 → 4.8.0-dev.20220519

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220516";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220519";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -59127,9 +59127,9 @@ var ts;
59127
59127
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
59128
59128
  t.flags & 402653316 /* StringLike */ ? globalStringType :
59129
59129
  t.flags & 296 /* NumberLike */ ? globalNumberType :
59130
- t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) :
59130
+ t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() :
59131
59131
  t.flags & 528 /* BooleanLike */ ? globalBooleanType :
59132
- t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) :
59132
+ t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() :
59133
59133
  t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType :
59134
59134
  t.flags & 4194304 /* Index */ ? keyofConstraintType :
59135
59135
  t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType :
@@ -60704,8 +60704,8 @@ var ts;
60704
60704
  function getGlobalESSymbolConstructorTypeSymbol(reportErrors) {
60705
60705
  return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors));
60706
60706
  }
60707
- function getGlobalESSymbolType(reportErrors) {
60708
- return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors))) || emptyObjectType;
60707
+ function getGlobalESSymbolType() {
60708
+ return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
60709
60709
  }
60710
60710
  function getGlobalPromiseType(reportErrors) {
60711
60711
  return (deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors))) || emptyGenericType;
@@ -60769,8 +60769,8 @@ var ts;
60769
60769
  deferredGlobalAwaitedSymbol || (deferredGlobalAwaitedSymbol = getGlobalTypeAliasSymbol("Awaited", /*arity*/ 1, reportErrors) || (reportErrors ? unknownSymbol : undefined));
60770
60770
  return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
60771
60771
  }
60772
- function getGlobalBigIntType(reportErrors) {
60773
- return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors))) || emptyObjectType;
60772
+ function getGlobalBigIntType() {
60773
+ return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
60774
60774
  }
60775
60775
  /**
60776
60776
  * Instantiates a global type that is generic with some element type, and returns that instantiation.
@@ -64922,7 +64922,7 @@ var ts;
64922
64922
  if ((globalStringType === source && stringType === target) ||
64923
64923
  (globalNumberType === source && numberType === target) ||
64924
64924
  (globalBooleanType === source && booleanType === target) ||
64925
- (getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) {
64925
+ (getGlobalESSymbolType() === source && esSymbolType === target)) {
64926
64926
  reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
64927
64927
  }
64928
64928
  }
@@ -82810,7 +82810,7 @@ var ts;
82810
82810
  var childSymbol = getSymbolAtLocation(childNode);
82811
82811
  if (childSymbol && childSymbol === testedSymbol) {
82812
82812
  // If the test was a simple identifier, the above check is sufficient
82813
- if (ts.isIdentifier(expr)) {
82813
+ if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
82814
82814
  return true;
82815
82815
  }
82816
82816
  // Otherwise we need to ensure the symbol is called on the same target
@@ -116024,7 +116024,7 @@ var ts;
116024
116024
  };
116025
116025
  }
116026
116026
  // directoryExists
116027
- if (originalDirectoryExists && originalCreateDirectory) {
116027
+ if (originalDirectoryExists) {
116028
116028
  host.directoryExists = function (directory) {
116029
116029
  var key = toPath(directory);
116030
116030
  var value = directoryExistsCache.get(key);
@@ -116034,11 +116034,13 @@ var ts;
116034
116034
  directoryExistsCache.set(key, !!newValue);
116035
116035
  return newValue;
116036
116036
  };
116037
- host.createDirectory = function (directory) {
116038
- var key = toPath(directory);
116039
- directoryExistsCache.delete(key);
116040
- originalCreateDirectory.call(host, directory);
116041
- };
116037
+ if (originalCreateDirectory) {
116038
+ host.createDirectory = function (directory) {
116039
+ var key = toPath(directory);
116040
+ directoryExistsCache.delete(key);
116041
+ originalCreateDirectory.call(host, directory);
116042
+ };
116043
+ }
116042
116044
  }
116043
116045
  return {
116044
116046
  originalReadFile: originalReadFile,
@@ -128424,6 +128426,41 @@ var ts;
128424
128426
  return true;
128425
128427
  }
128426
128428
  ts.isTextWhiteSpaceLike = isTextWhiteSpaceLike;
128429
+ function getMappedLocation(location, sourceMapper, fileExists) {
128430
+ var mapsTo = sourceMapper.tryGetSourcePosition(location);
128431
+ return mapsTo && (!fileExists || fileExists(ts.normalizePath(mapsTo.fileName)) ? mapsTo : undefined);
128432
+ }
128433
+ ts.getMappedLocation = getMappedLocation;
128434
+ function getMappedDocumentSpan(documentSpan, sourceMapper, fileExists) {
128435
+ var fileName = documentSpan.fileName, textSpan = documentSpan.textSpan;
128436
+ var newPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start }, sourceMapper, fileExists);
128437
+ if (!newPosition)
128438
+ return undefined;
128439
+ var newEndPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start + textSpan.length }, sourceMapper, fileExists);
128440
+ var newLength = newEndPosition
128441
+ ? newEndPosition.pos - newPosition.pos
128442
+ : textSpan.length; // This shouldn't happen
128443
+ return {
128444
+ fileName: newPosition.fileName,
128445
+ textSpan: {
128446
+ start: newPosition.pos,
128447
+ length: newLength,
128448
+ },
128449
+ originalFileName: documentSpan.fileName,
128450
+ originalTextSpan: documentSpan.textSpan,
128451
+ contextSpan: getMappedContextSpan(documentSpan, sourceMapper, fileExists),
128452
+ originalContextSpan: documentSpan.contextSpan
128453
+ };
128454
+ }
128455
+ ts.getMappedDocumentSpan = getMappedDocumentSpan;
128456
+ function getMappedContextSpan(documentSpan, sourceMapper, fileExists) {
128457
+ var contextSpanStart = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start }, sourceMapper, fileExists);
128458
+ var contextSpanEnd = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length }, sourceMapper, fileExists);
128459
+ return contextSpanStart && contextSpanEnd ?
128460
+ { start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } :
128461
+ undefined;
128462
+ }
128463
+ ts.getMappedContextSpan = getMappedContextSpan;
128427
128464
  // #endregion
128428
128465
  // Display-part writer helpers
128429
128466
  // #region
@@ -137345,6 +137382,7 @@ var ts;
137345
137382
  var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined;
137346
137383
  return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; })));
137347
137384
  }
137385
+ FindAllReferences.isDeclarationOfSymbol = isDeclarationOfSymbol;
137348
137386
  /**
137349
137387
  * True if 'decl' provides a value, as in `function f() {}`;
137350
137388
  * false if 'decl' is just a location for a future write, as in 'let x;'
@@ -164504,9 +164542,8 @@ var ts;
164504
164542
  var isStaticMember = ts.hasStaticModifier(declaration);
164505
164543
  return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) {
164506
164544
  var baseType = checker.getTypeAtLocation(superTypeNode);
164507
- var symbol = isStaticMember
164508
- ? ts.find(checker.getExportsOfModule(baseType.symbol), function (s) { return s.escapedName === declaration.symbol.name; })
164509
- : checker.getPropertyOfType(baseType, declaration.symbol.name);
164545
+ var type = isStaticMember && baseType.symbol ? checker.getTypeOfSymbol(baseType.symbol) : baseType;
164546
+ var symbol = checker.getPropertyOfType(type, declaration.symbol.name);
164510
164547
  return symbol ? cb(symbol) : undefined;
164511
164548
  });
164512
164549
  }
@@ -164749,70 +164786,6 @@ var ts;
164749
164786
  return ts.codefix.getSupportedErrorCodes();
164750
164787
  }
164751
164788
  ts.getSupportedCodeFixes = getSupportedCodeFixes;
164752
- // Cache host information about script Should be refreshed
164753
- // at each language service public entry point, since we don't know when
164754
- // the set of scripts handled by the host changes.
164755
- var HostCache = /** @class */ (function () {
164756
- function HostCache(host, getCanonicalFileName) {
164757
- this.host = host;
164758
- // script id => script index
164759
- this.currentDirectory = host.getCurrentDirectory();
164760
- this.fileNameToEntry = new ts.Map();
164761
- // Initialize the list with the root file names
164762
- var rootFileNames = host.getScriptFileNames();
164763
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
164764
- for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
164765
- var fileName = rootFileNames_1[_i];
164766
- this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
164767
- }
164768
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
164769
- }
164770
- HostCache.prototype.createEntry = function (fileName, path) {
164771
- var entry;
164772
- var scriptSnapshot = this.host.getScriptSnapshot(fileName);
164773
- if (scriptSnapshot) {
164774
- entry = {
164775
- hostFileName: fileName,
164776
- version: this.host.getScriptVersion(fileName),
164777
- scriptSnapshot: scriptSnapshot,
164778
- scriptKind: ts.getScriptKind(fileName, this.host)
164779
- };
164780
- }
164781
- else {
164782
- entry = fileName;
164783
- }
164784
- this.fileNameToEntry.set(path, entry);
164785
- return entry;
164786
- };
164787
- HostCache.prototype.getEntryByPath = function (path) {
164788
- return this.fileNameToEntry.get(path);
164789
- };
164790
- HostCache.prototype.getHostFileInformation = function (path) {
164791
- var entry = this.fileNameToEntry.get(path);
164792
- return !ts.isString(entry) ? entry : undefined;
164793
- };
164794
- HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) {
164795
- var info = this.getEntryByPath(path) || this.createEntry(fileName, path);
164796
- return ts.isString(info) ? undefined : info; // TODO: GH#18217
164797
- };
164798
- HostCache.prototype.getRootFileNames = function () {
164799
- var names = [];
164800
- this.fileNameToEntry.forEach(function (entry) {
164801
- if (ts.isString(entry)) {
164802
- names.push(entry);
164803
- }
164804
- else {
164805
- names.push(entry.hostFileName);
164806
- }
164807
- });
164808
- return names;
164809
- };
164810
- HostCache.prototype.getScriptSnapshot = function (path) {
164811
- var file = this.getHostFileInformation(path);
164812
- return (file && file.scriptSnapshot); // TODO: GH#18217
164813
- };
164814
- return HostCache;
164815
- }());
164816
164789
  var SyntaxTreeCache = /** @class */ (function () {
164817
164790
  function SyntaxTreeCache(host) {
164818
164791
  this.host = host;
@@ -165074,32 +165047,13 @@ var ts;
165074
165047
  program = undefined; // TODO: GH#18217
165075
165048
  lastTypesRootVersion = typeRootsVersion;
165076
165049
  }
165050
+ var rootFileNames = host.getScriptFileNames();
165077
165051
  // Get a fresh cache of the host information
165078
- var hostCache = new HostCache(host, getCanonicalFileName);
165079
- var rootFileNames = hostCache.getRootFileNames();
165080
165052
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
165081
165053
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
165082
165054
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
165083
165055
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
165084
165056
  var parsedCommandLines;
165085
- var parseConfigHost = {
165086
- useCaseSensitiveFileNames: useCaseSensitiveFileNames,
165087
- fileExists: fileExists,
165088
- readFile: readFile,
165089
- readDirectory: readDirectory,
165090
- trace: ts.maybeBind(host, host.trace),
165091
- getCurrentDirectory: function () { return currentDirectory; },
165092
- onUnRecoverableConfigFileDiagnostic: ts.noop,
165093
- };
165094
- // If the program is already up-to-date, we can reuse it
165095
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
165096
- return;
165097
- }
165098
- // IMPORTANT - It is critical from this moment onward that we do not check
165099
- // cancellation tokens. We are about to mutate source files from a previous program
165100
- // instance. If we cancel midway through, we may end up in an inconsistent state where
165101
- // the program points to old source files that have been invalidated because of
165102
- // incremental parsing.
165103
165057
  // Now create a new compiler
165104
165058
  var compilerHost = {
165105
165059
  getSourceFile: getOrCreateSourceFile,
@@ -165111,8 +165065,8 @@ var ts;
165111
165065
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
165112
165066
  writeFile: ts.noop,
165113
165067
  getCurrentDirectory: function () { return currentDirectory; },
165114
- fileExists: fileExists,
165115
- readFile: readFile,
165068
+ fileExists: function (fileName) { return host.fileExists(fileName); },
165069
+ readFile: function (fileName) { return host.readFile && host.readFile(fileName); },
165116
165070
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
165117
165071
  realpath: ts.maybeBind(host, host.realpath),
165118
165072
  directoryExists: function (directoryName) {
@@ -165121,19 +165075,56 @@ var ts;
165121
165075
  getDirectories: function (path) {
165122
165076
  return host.getDirectories ? host.getDirectories(path) : [];
165123
165077
  },
165124
- readDirectory: readDirectory,
165078
+ readDirectory: function (path, extensions, exclude, include, depth) {
165079
+ ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
165080
+ return host.readDirectory(path, extensions, exclude, include, depth);
165081
+ },
165125
165082
  onReleaseOldSourceFile: onReleaseOldSourceFile,
165126
165083
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
165127
165084
  hasInvalidatedResolution: hasInvalidatedResolution,
165128
165085
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
165129
- trace: parseConfigHost.trace,
165086
+ trace: ts.maybeBind(host, host.trace),
165130
165087
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
165131
165088
  getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
165132
165089
  resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
165133
165090
  useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
165134
165091
  getParsedCommandLine: getParsedCommandLine,
165135
165092
  };
165093
+ var originalGetSourceFile = compilerHost.getSourceFile;
165094
+ var getSourceFileWithCache = ts.changeCompilerHostLikeToUseCache(compilerHost, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); }, function () {
165095
+ var args = [];
165096
+ for (var _i = 0; _i < arguments.length; _i++) {
165097
+ args[_i] = arguments[_i];
165098
+ }
165099
+ return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args, false));
165100
+ }).getSourceFileWithCache;
165101
+ compilerHost.getSourceFile = getSourceFileWithCache;
165136
165102
  (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost);
165103
+ var parseConfigHost = {
165104
+ useCaseSensitiveFileNames: useCaseSensitiveFileNames,
165105
+ fileExists: function (fileName) { return compilerHost.fileExists(fileName); },
165106
+ readFile: function (fileName) { return compilerHost.readFile(fileName); },
165107
+ readDirectory: function () {
165108
+ var _a;
165109
+ var args = [];
165110
+ for (var _i = 0; _i < arguments.length; _i++) {
165111
+ args[_i] = arguments[_i];
165112
+ }
165113
+ return (_a = compilerHost).readDirectory.apply(_a, args);
165114
+ },
165115
+ trace: compilerHost.trace,
165116
+ getCurrentDirectory: compilerHost.getCurrentDirectory,
165117
+ onUnRecoverableConfigFileDiagnostic: ts.noop,
165118
+ };
165119
+ // If the program is already up-to-date, we can reuse it
165120
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
165121
+ return;
165122
+ }
165123
+ // IMPORTANT - It is critical from this moment onward that we do not check
165124
+ // cancellation tokens. We are about to mutate source files from a previous program
165125
+ // instance. If we cancel midway through, we may end up in an inconsistent state where
165126
+ // the program points to old source files that have been invalidated because of
165127
+ // incremental parsing.
165137
165128
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
165138
165129
  var options = {
165139
165130
  rootNames: rootFileNames,
@@ -165143,9 +165134,9 @@ var ts;
165143
165134
  projectReferences: projectReferences
165144
165135
  };
165145
165136
  program = ts.createProgram(options);
165146
- // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
165147
- // It needs to be cleared to allow all collected snapshots to be released
165148
- hostCache = undefined;
165137
+ // 'getOrCreateSourceFile' depends on caching but should be used past this point.
165138
+ // After this point, the cache needs to be cleared to allow all collected snapshots to be released
165139
+ compilerHost = undefined;
165149
165140
  parsedCommandLines = undefined;
165150
165141
  // 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,
165151
165142
  // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during
@@ -165185,26 +165176,6 @@ var ts;
165185
165176
  onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
165186
165177
  }
165187
165178
  }
165188
- function fileExists(fileName) {
165189
- var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
165190
- var entry = hostCache && hostCache.getEntryByPath(path);
165191
- return entry ?
165192
- !ts.isString(entry) :
165193
- (!!host.fileExists && host.fileExists(fileName));
165194
- }
165195
- function readFile(fileName) {
165196
- // stub missing host functionality
165197
- var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
165198
- var entry = hostCache && hostCache.getEntryByPath(path);
165199
- if (entry) {
165200
- return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot);
165201
- }
165202
- return host.readFile && host.readFile(fileName);
165203
- }
165204
- function readDirectory(path, extensions, exclude, include, depth) {
165205
- ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
165206
- return host.readDirectory(path, extensions, exclude, include, depth);
165207
- }
165208
165179
  // Release any files we have acquired in the old program but are
165209
165180
  // not part of the new program.
165210
165181
  function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
@@ -165215,14 +165186,16 @@ var ts;
165215
165186
  return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile);
165216
165187
  }
165217
165188
  function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) {
165218
- ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
165189
+ ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
165219
165190
  // The program is asking for this file, check first if the host can locate it.
165220
165191
  // If the host can not locate the file, then it does not exist. return undefined
165221
165192
  // to the program to allow reporting of errors for missing files.
165222
- var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path);
165223
- if (!hostFileInformation) {
165193
+ var scriptSnapshot = host.getScriptSnapshot(fileName);
165194
+ if (!scriptSnapshot) {
165224
165195
  return undefined;
165225
165196
  }
165197
+ var scriptKind = ts.getScriptKind(fileName, host);
165198
+ var scriptVersion = host.getScriptVersion(fileName);
165226
165199
  // Check if the language version has changed since we last created a program; if they are the same,
165227
165200
  // it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile
165228
165201
  // can not be reused. we have to dump all syntax trees and create new ones.
@@ -165254,8 +165227,8 @@ var ts;
165254
165227
  // We do not support the scenario where a host can modify a registered
165255
165228
  // file's script kind, i.e. in one project some file is treated as ".ts"
165256
165229
  // and in another as ".js"
165257
- if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
165258
- return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
165230
+ if (scriptKind === oldSourceFile.scriptKind) {
165231
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
165259
165232
  }
165260
165233
  else {
165261
165234
  // Release old source file and fall through to aquire new file with new script kind
@@ -165265,7 +165238,7 @@ var ts;
165265
165238
  // We didn't already have the file. Fall through and acquire it from the registry.
165266
165239
  }
165267
165240
  // Could not find this file in the old program, create a new SourceFile for it.
165268
- return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
165241
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
165269
165242
  }
165270
165243
  }
165271
165244
  // TODO: GH#18217 frequently asserted as defined
@@ -165281,6 +165254,61 @@ var ts;
165281
165254
  var _a;
165282
165255
  return (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host);
165283
165256
  }
165257
+ function updateIsDefinitionOfReferencedSymbols(referencedSymbols, knownSymbolSpans) {
165258
+ var checker = program.getTypeChecker();
165259
+ var symbol = getSymbolForProgram();
165260
+ if (!symbol)
165261
+ return false;
165262
+ for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) {
165263
+ var referencedSymbol = referencedSymbols_1[_i];
165264
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
165265
+ var ref = _b[_a];
165266
+ var refNode = getNodeForSpan(ref);
165267
+ ts.Debug.assertIsDefined(refNode);
165268
+ if (knownSymbolSpans.has(ref) || ts.FindAllReferences.isDeclarationOfSymbol(refNode, symbol)) {
165269
+ knownSymbolSpans.add(ref);
165270
+ ref.isDefinition = true;
165271
+ var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
165272
+ if (mappedSpan) {
165273
+ knownSymbolSpans.add(mappedSpan);
165274
+ }
165275
+ }
165276
+ else {
165277
+ ref.isDefinition = false;
165278
+ }
165279
+ }
165280
+ }
165281
+ return true;
165282
+ function getSymbolForProgram() {
165283
+ for (var _i = 0, referencedSymbols_2 = referencedSymbols; _i < referencedSymbols_2.length; _i++) {
165284
+ var referencedSymbol = referencedSymbols_2[_i];
165285
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
165286
+ var ref = _b[_a];
165287
+ if (knownSymbolSpans.has(ref)) {
165288
+ var refNode = getNodeForSpan(ref);
165289
+ ts.Debug.assertIsDefined(refNode);
165290
+ return checker.getSymbolAtLocation(refNode);
165291
+ }
165292
+ var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
165293
+ if (mappedSpan && knownSymbolSpans.has(mappedSpan)) {
165294
+ var refNode = getNodeForSpan(mappedSpan);
165295
+ if (refNode) {
165296
+ return checker.getSymbolAtLocation(refNode);
165297
+ }
165298
+ }
165299
+ }
165300
+ }
165301
+ return undefined;
165302
+ }
165303
+ function getNodeForSpan(docSpan) {
165304
+ var sourceFile = program.getSourceFile(docSpan.fileName);
165305
+ if (!sourceFile)
165306
+ return undefined;
165307
+ var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start);
165308
+ var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ });
165309
+ return adjustedNode;
165310
+ }
165311
+ }
165284
165312
  function cleanupSemanticCache() {
165285
165313
  program = undefined; // TODO: GH#18217
165286
165314
  }
@@ -166207,6 +166235,7 @@ var ts;
166207
166235
  getNonBoundSourceFile: getNonBoundSourceFile,
166208
166236
  getProgram: getProgram,
166209
166237
  getAutoImportProvider: getAutoImportProvider,
166238
+ updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
166210
166239
  getApplicableRefactors: getApplicableRefactors,
166211
166240
  getEditsForRefactor: getEditsForRefactor,
166212
166241
  toLineColumnOffset: toLineColumnOffset,