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.
@@ -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,
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220516";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220519";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -58922,9 +58922,9 @@ var ts;
58922
58922
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
58923
58923
  t.flags & 402653316 /* StringLike */ ? globalStringType :
58924
58924
  t.flags & 296 /* NumberLike */ ? globalNumberType :
58925
- t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) :
58925
+ t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() :
58926
58926
  t.flags & 528 /* BooleanLike */ ? globalBooleanType :
58927
- t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) :
58927
+ t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() :
58928
58928
  t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType :
58929
58929
  t.flags & 4194304 /* Index */ ? keyofConstraintType :
58930
58930
  t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType :
@@ -60499,8 +60499,8 @@ var ts;
60499
60499
  function getGlobalESSymbolConstructorTypeSymbol(reportErrors) {
60500
60500
  return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors));
60501
60501
  }
60502
- function getGlobalESSymbolType(reportErrors) {
60503
- return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors))) || emptyObjectType;
60502
+ function getGlobalESSymbolType() {
60503
+ return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
60504
60504
  }
60505
60505
  function getGlobalPromiseType(reportErrors) {
60506
60506
  return (deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors))) || emptyGenericType;
@@ -60564,8 +60564,8 @@ var ts;
60564
60564
  deferredGlobalAwaitedSymbol || (deferredGlobalAwaitedSymbol = getGlobalTypeAliasSymbol("Awaited", /*arity*/ 1, reportErrors) || (reportErrors ? unknownSymbol : undefined));
60565
60565
  return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
60566
60566
  }
60567
- function getGlobalBigIntType(reportErrors) {
60568
- return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors))) || emptyObjectType;
60567
+ function getGlobalBigIntType() {
60568
+ return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
60569
60569
  }
60570
60570
  /**
60571
60571
  * Instantiates a global type that is generic with some element type, and returns that instantiation.
@@ -64717,7 +64717,7 @@ var ts;
64717
64717
  if ((globalStringType === source && stringType === target) ||
64718
64718
  (globalNumberType === source && numberType === target) ||
64719
64719
  (globalBooleanType === source && booleanType === target) ||
64720
- (getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) {
64720
+ (getGlobalESSymbolType() === source && esSymbolType === target)) {
64721
64721
  reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
64722
64722
  }
64723
64723
  }
@@ -82605,7 +82605,7 @@ var ts;
82605
82605
  var childSymbol = getSymbolAtLocation(childNode);
82606
82606
  if (childSymbol && childSymbol === testedSymbol) {
82607
82607
  // If the test was a simple identifier, the above check is sufficient
82608
- if (ts.isIdentifier(expr)) {
82608
+ if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
82609
82609
  return true;
82610
82610
  }
82611
82611
  // Otherwise we need to ensure the symbol is called on the same target
@@ -115819,7 +115819,7 @@ var ts;
115819
115819
  };
115820
115820
  }
115821
115821
  // directoryExists
115822
- if (originalDirectoryExists && originalCreateDirectory) {
115822
+ if (originalDirectoryExists) {
115823
115823
  host.directoryExists = function (directory) {
115824
115824
  var key = toPath(directory);
115825
115825
  var value = directoryExistsCache.get(key);
@@ -115829,11 +115829,13 @@ var ts;
115829
115829
  directoryExistsCache.set(key, !!newValue);
115830
115830
  return newValue;
115831
115831
  };
115832
- host.createDirectory = function (directory) {
115833
- var key = toPath(directory);
115834
- directoryExistsCache.delete(key);
115835
- originalCreateDirectory.call(host, directory);
115836
- };
115832
+ if (originalCreateDirectory) {
115833
+ host.createDirectory = function (directory) {
115834
+ var key = toPath(directory);
115835
+ directoryExistsCache.delete(key);
115836
+ originalCreateDirectory.call(host, directory);
115837
+ };
115838
+ }
115837
115839
  }
115838
115840
  return {
115839
115841
  originalReadFile: originalReadFile,
@@ -377,6 +377,8 @@
377
377
  "Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclas_2720": "类“{0}”错误实现类“{1}”。你是想扩展“{1}”并将其成员作为子类继承吗?",
378
378
  "Class_0_incorrectly_implements_interface_1_2420": "类“{0}”错误实现接口“{1}”。",
379
379
  "Class_0_used_before_its_declaration_2449": "类“{0}”用于其声明前。",
380
+ "Class_constructor_may_not_be_a_generator_1360": "类构造函数可能不是生成器。",
381
+ "Class_constructor_may_not_be_an_accessor_1341": "类构造函数可能不是访问器。",
380
382
  "Class_declaration_cannot_implement_overload_list_for_0_2813": "类声明无法实现“{0}”的重载列表。",
381
383
  "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "类声明不能有多个 “@augments” 或 “@extends” 标记。",
382
384
  "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036": "类修饰器不能与静态专用标识符一起使用。请考虑删除实验性修饰器。",
@@ -1455,6 +1457,7 @@
1455
1457
  "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410": "不支持 \"with\" 语句。\"with\" 程序块中的所有符号都将具有类型 \"any\"。",
1456
1458
  "This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided_2746": "此 JSX 标记的 \"{0}\" 属性需要 \"{1}\" 类型的子级,但提供了多个子级。",
1457
1459
  "This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_pr_2745": "此 JSX 标记的 \"{0}\" 属性需要类型 \"{1}\",该类型需要多个子级,但仅提供了一个子级。",
1460
+ "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839": "此条件将始终返回“{0}”,因为 JavaScript 按引用而不是值比较对象。",
1458
1461
  "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367": "此条件将始终返回 \"{0}\",因为类型 \"{1}\" 和 \"{2}\" 没有重叠。",
1459
1462
  "This_condition_will_always_return_true_since_this_0_is_always_defined_2801": "此条件将始终返回 true,因为此“{0}”已始终定义。",
1460
1463
  "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774": "此条件将始终返回 true,因为始终定义了函数。你是想改为调用它吗?",
@@ -377,6 +377,8 @@
377
377
  "Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclas_2720": "類別 '{0}' 不當實作類別 '{1}'。您是否要擴充 '{1}',並繼承其成員以成為子類別?",
378
378
  "Class_0_incorrectly_implements_interface_1_2420": "類別 '{0}' 不正確地實作介面 '{1}'。",
379
379
  "Class_0_used_before_its_declaration_2449": "類別 '{0}' 的位置在其宣告之前。",
380
+ "Class_constructor_may_not_be_a_generator_1360": "類別建構函式可能不是產生器。",
381
+ "Class_constructor_may_not_be_an_accessor_1341": "類別建構函式可能不是存取子。",
380
382
  "Class_declaration_cannot_implement_overload_list_for_0_2813": "類別宣告無法為 '{0}' 實作多載清單。",
381
383
  "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "類別宣告不能有一個以上的 `@augments` 或 `@extends` 標籤。",
382
384
  "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036": "類別裝飾項目無法與靜態私人識別碼一起使用。請考慮移除實驗性裝飾項目。",
@@ -1455,6 +1457,7 @@
1455
1457
  "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410": "不支援 'with' 陳述式。'with' 區塊中的所有符號都會有類型 'any'。",
1456
1458
  "This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided_2746": "此 JSX 標籤的 '{0}' 屬性只能有一個 '{1}' 類型的子系,但提供的子系卻有多個。",
1457
1459
  "This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_pr_2745": "此 JSX 標籤的 '{0}' 屬性需要必須有多個子系的類型 '{1}',但僅提供的子系只有一個。",
1460
+ "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839": "此條件一律會傳回 '{0}',因為 JavaScript 會依參照而非值比較物件。",
1458
1461
  "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367": "因為類型 '{1}' 與 '{2}' 未重疊,所以此條件永遠會傳回 '{0}'。",
1459
1462
  "This_condition_will_always_return_true_since_this_0_is_always_defined_2801": "因為此 '{0}' 一律會被定義,所以此條件一律傳回 True。",
1460
1463
  "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774": "因為永遠會定義此函式,所以此條件永遠會傳回 true。您是要改為呼叫該條件嗎?",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.8.0-dev.20220516",
5
+ "version": "4.8.0-dev.20220519",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [