typescript 4.9.0-dev.20220921 → 4.9.0-dev.20220923

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
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220921");
112
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220923");
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -45253,6 +45253,7 @@ var ts;
45253
45253
  }
45254
45254
  }
45255
45255
  function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
45256
+ var _a;
45256
45257
  var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
45257
45258
  // First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
45258
45259
  var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
@@ -45267,13 +45268,7 @@ var ts;
45267
45268
  return withPackageId(packageInfo, fromDirectory);
45268
45269
  }
45269
45270
  }
45270
- var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
45271
45271
  var loader = function (extensions, candidate, onlyRecordFailures, state) {
45272
- var _a;
45273
- // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
45274
- if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45275
- return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45276
- }
45277
45272
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
45278
45273
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.contents.packageJsonContent, packageInfo && packageInfo.contents.versionPaths);
45279
45274
  if (!pathAndExtension && packageInfo
@@ -45286,19 +45281,24 @@ var ts;
45286
45281
  }
45287
45282
  return withPackageId(packageInfo, pathAndExtension);
45288
45283
  };
45289
- if (rest !== "") { // If "rest" is empty, we just did this search above.
45290
- var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45291
- // Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
45284
+ var _b = parsePackageName(moduleName), packageName = _b.packageName, rest = _b.rest;
45285
+ var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45286
+ if (rest !== "") {
45287
+ // Previous `packageInfo` may have been from a nested package.json; ensure we have the one from the package root now.
45292
45288
  packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
45293
- if (packageInfo && packageInfo.contents.versionPaths) {
45294
- if (state.traceEnabled) {
45295
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, ts.version, rest);
45296
- }
45297
- var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45298
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45299
- if (fromPaths) {
45300
- return fromPaths.value;
45301
- }
45289
+ }
45290
+ // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them)
45291
+ if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45292
+ return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45293
+ }
45294
+ if (rest !== "" && packageInfo && packageInfo.contents.versionPaths) {
45295
+ if (state.traceEnabled) {
45296
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, ts.version, rest);
45297
+ }
45298
+ var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45299
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45300
+ if (fromPaths) {
45301
+ return fromPaths.value;
45302
45302
  }
45303
45303
  }
45304
45304
  return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
@@ -55479,6 +55479,7 @@ var ts;
55479
55479
  && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
55480
55480
  && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */)
55481
55481
  && !(symbol.flags & 32 /* SymbolFlags.Class */)
55482
+ && !(symbol.flags & 8192 /* SymbolFlags.Method */)
55482
55483
  && !isConstMergedWithNSPrintableAsSignatureMerge) {
55483
55484
  if (propertyAsAlias) {
55484
55485
  var createdExport = serializeMaybeAliasAssignment(symbol);
@@ -115413,6 +115414,7 @@ var ts;
115413
115414
  writeTrailingSemicolon();
115414
115415
  }
115415
115416
  function emitExportDeclaration(node) {
115417
+ emitModifiers(node, node.modifiers);
115416
115418
  var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
115417
115419
  writeSpace();
115418
115420
  if (node.isTypeOnly) {
@@ -118838,7 +118840,7 @@ var ts;
118838
118840
  * Determines if program structure is upto date or needs to be recreated
118839
118841
  */
118840
118842
  /* @internal */
118841
- function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118843
+ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118842
118844
  // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date
118843
118845
  if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames()))
118844
118846
  return false;
@@ -118866,7 +118868,7 @@ var ts;
118866
118868
  return true;
118867
118869
  function sourceFileNotUptoDate(sourceFile) {
118868
118870
  return !sourceFileVersionUptoDate(sourceFile) ||
118869
- hasInvalidatedResolution(sourceFile.path);
118871
+ hasInvalidatedResolutions(sourceFile.path);
118870
118872
  }
118871
118873
  function sourceFileVersionUptoDate(sourceFile) {
118872
118874
  return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
@@ -119112,7 +119114,7 @@ var ts;
119112
119114
  var moduleResolutionCache;
119113
119115
  var typeReferenceDirectiveResolutionCache;
119114
119116
  var actualResolveModuleNamesWorker;
119115
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
119117
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
119116
119118
  if (host.resolveModuleNames) {
119117
119119
  actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
119118
119120
  // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -119559,7 +119561,7 @@ var ts;
119559
119561
  for (var i = 0; i < moduleNames.length; i++) {
119560
119562
  var moduleName = moduleNames[i];
119561
119563
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
119562
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
119564
+ if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
119563
119565
  var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
119564
119566
  if (oldResolvedModule) {
119565
119567
  if (ts.isTraceEnabled(options, host)) {
@@ -119795,7 +119797,7 @@ var ts;
119795
119797
  // tentatively approve the file
119796
119798
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119797
119799
  }
119798
- else if (hasInvalidatedResolution(oldSourceFile.path)) {
119800
+ else if (hasInvalidatedResolutions(oldSourceFile.path)) {
119799
119801
  // 'module/types' references could have changed
119800
119802
  structureIsReused = 1 /* StructureIsReused.SafeModules */;
119801
119803
  // add file to the modified list so that we will resolve it later
@@ -123841,7 +123843,7 @@ var ts;
123841
123843
  invalidateResolutionOfFile: invalidateResolutionOfFile,
123842
123844
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
123843
123845
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
123844
- createHasInvalidatedResolution: createHasInvalidatedResolution,
123846
+ createHasInvalidatedResolutions: createHasInvalidatedResolutions,
123845
123847
  isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
123846
123848
  updateTypeRootsWatch: updateTypeRootsWatch,
123847
123849
  closeTypeRootsWatch: closeTypeRootsWatch,
@@ -123896,17 +123898,13 @@ var ts;
123896
123898
  var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
123897
123899
  return !!value && !!value.length;
123898
123900
  }
123899
- function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
123901
+ function createHasInvalidatedResolutions(customHasInvalidatedResolutions) {
123900
123902
  // Ensure pending resolutions are applied
123901
123903
  invalidateResolutionsOfFailedLookupLocations();
123902
- if (forceAllFilesAsInvalidated) {
123903
- // Any file asked would have invalidated resolution
123904
- filesWithInvalidatedResolutions = undefined;
123905
- return ts.returnTrue;
123906
- }
123907
123904
  var collected = filesWithInvalidatedResolutions;
123908
123905
  filesWithInvalidatedResolutions = undefined;
123909
- return function (path) { return (!!collected && collected.has(path)) ||
123906
+ return function (path) { return customHasInvalidatedResolutions(path) ||
123907
+ !!(collected === null || collected === void 0 ? void 0 : collected.has(path)) ||
123910
123908
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123911
123909
  }
123912
123910
  function startCachingPerDirectoryResolution() {
@@ -126286,6 +126284,10 @@ var ts;
126286
126284
  ts.maybeBind(host, host.getModuleResolutionCache) :
126287
126285
  (function () { return resolutionCache.getModuleResolutionCache(); });
126288
126286
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
126287
+ // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions
126288
+ var customHasInvalidatedResolutions = userProvidedResolution ?
126289
+ ts.maybeBind(host, host.hasInvalidatedResolutions) || ts.returnTrue :
126290
+ ts.returnFalse;
126289
126291
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
126290
126292
  synchronizeProgram();
126291
126293
  // Update the wild card directory watch
@@ -126351,10 +126353,9 @@ var ts;
126351
126353
  resolutionCache.clear();
126352
126354
  }
126353
126355
  }
126354
- // All resolutions are invalid if user provided resolutions
126355
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
126356
+ var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
126356
126357
  var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
126357
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126358
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126358
126359
  if (hasChangedConfigFileParsingErrors) {
126359
126360
  if (reportFileChangeDetectedOnCreateProgram) {
126360
126361
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -126367,7 +126368,7 @@ var ts;
126367
126368
  if (reportFileChangeDetectedOnCreateProgram) {
126368
126369
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
126369
126370
  }
126370
- createNewProgram(hasInvalidatedResolution);
126371
+ createNewProgram(hasInvalidatedResolutions);
126371
126372
  }
126372
126373
  reportFileChangeDetectedOnCreateProgram = false;
126373
126374
  if (host.afterProgramCreate && program !== builderProgram) {
@@ -126380,7 +126381,7 @@ var ts;
126380
126381
  compilerHost.writeFile = originalWriteFile;
126381
126382
  return builderProgram;
126382
126383
  }
126383
- function createNewProgram(hasInvalidatedResolution) {
126384
+ function createNewProgram(hasInvalidatedResolutions) {
126384
126385
  // Compile the program
126385
126386
  writeLog("CreatingProgramWith::");
126386
126387
  writeLog(" roots: ".concat(JSON.stringify(rootFileNames)));
@@ -126391,7 +126392,7 @@ var ts;
126391
126392
  hasChangedCompilerOptions = false;
126392
126393
  hasChangedConfigFileParsingErrors = false;
126393
126394
  resolutionCache.startCachingPerDirectoryResolution();
126394
- compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
126395
+ compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
126395
126396
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
126396
126397
  var oldProgram = getCurrentProgram();
126397
126398
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
@@ -139175,7 +139176,7 @@ var ts;
139175
139176
  break;
139176
139177
  case 202 /* SyntaxKind.ImportType */:
139177
139178
  // Only check for typeof import('xyz')
139178
- if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139179
+ if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139179
139180
  addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
139180
139181
  }
139181
139182
  directImports.push(direct);
@@ -146341,6 +146342,10 @@ var ts;
146341
146342
  pushSelectionCommentRange(comment.pos, comment.end);
146342
146343
  }
146343
146344
  if (positionShouldSnapToNode(sourceFile, pos, node)) {
146345
+ if (ts.isFunctionBody(node)
146346
+ && ts.isFunctionLikeDeclaration(parentNode) && !ts.positionsAreOnSameLine(node.getStart(sourceFile), node.getEnd(), sourceFile)) {
146347
+ pushSelectionRange(node.getStart(sourceFile), node.getEnd());
146348
+ }
146344
146349
  // 1. Blocks are effectively redundant with SyntaxLists.
146345
146350
  // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
146346
146351
  // of things that should be considered independently.
@@ -157953,7 +157958,7 @@ var ts;
157953
157958
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157954
157959
  }
157955
157960
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
157956
- if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
157961
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
157957
157962
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
157958
157963
  }
157959
157964
  return undefined;
@@ -168333,7 +168338,7 @@ var ts;
168333
168338
  var rootFileNames = host.getScriptFileNames().slice();
168334
168339
  // Get a fresh cache of the host information
168335
168340
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
168336
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
168341
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
168337
168342
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
168338
168343
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
168339
168344
  var parsedCommandLines;
@@ -168364,7 +168369,7 @@ var ts;
168364
168369
  },
168365
168370
  onReleaseOldSourceFile: onReleaseOldSourceFile,
168366
168371
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
168367
- hasInvalidatedResolution: hasInvalidatedResolution,
168372
+ hasInvalidatedResolutions: hasInvalidatedResolutions,
168368
168373
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
168369
168374
  trace: ts.maybeBind(host, host.trace),
168370
168375
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
@@ -168404,7 +168409,7 @@ var ts;
168404
168409
  // as a const variable without downleveling, doesn't crash).
168405
168410
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
168406
168411
  // If the program is already up-to-date, we can reuse it
168407
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168412
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168408
168413
  return;
168409
168414
  }
168410
168415
  // IMPORTANT - It is critical from this moment onward that we do not check
@@ -173698,7 +173703,7 @@ var ts;
173698
173703
  ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
173699
173704
  this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName()));
173700
173705
  var start = ts.timestamp();
173701
- this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution();
173706
+ this.hasInvalidatedResolutions = this.resolutionCache.createHasInvalidatedResolutions(ts.returnFalse);
173702
173707
  this.resolutionCache.startCachingPerDirectoryResolution();
173703
173708
  this.program = this.languageService.getProgram(); // TODO: GH#18217
173704
173709
  this.dirty = false;
@@ -3320,6 +3320,8 @@ declare namespace ts {
3320
3320
  */
3321
3321
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
3322
3322
  getEnvironmentVariable?(name: string): string | undefined;
3323
+ /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
3324
+ hasInvalidatedResolutions?(filePath: Path): boolean;
3323
3325
  createHash?(data: string): string;
3324
3326
  getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
3325
3327
  }
@@ -5442,6 +5444,8 @@ declare namespace ts {
5442
5444
  resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
5443
5445
  /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
5444
5446
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
5447
+ /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
5448
+ hasInvalidatedResolutions?(filePath: Path): boolean;
5445
5449
  /**
5446
5450
  * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
5447
5451
  */
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220921");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220923");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -45252,6 +45252,7 @@ var ts;
45252
45252
  }
45253
45253
  }
45254
45254
  function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
45255
+ var _a;
45255
45256
  var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
45256
45257
  // First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
45257
45258
  var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
@@ -45266,13 +45267,7 @@ var ts;
45266
45267
  return withPackageId(packageInfo, fromDirectory);
45267
45268
  }
45268
45269
  }
45269
- var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
45270
45270
  var loader = function (extensions, candidate, onlyRecordFailures, state) {
45271
- var _a;
45272
- // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
45273
- if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45274
- return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45275
- }
45276
45271
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
45277
45272
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.contents.packageJsonContent, packageInfo && packageInfo.contents.versionPaths);
45278
45273
  if (!pathAndExtension && packageInfo
@@ -45285,19 +45280,24 @@ var ts;
45285
45280
  }
45286
45281
  return withPackageId(packageInfo, pathAndExtension);
45287
45282
  };
45288
- if (rest !== "") { // If "rest" is empty, we just did this search above.
45289
- var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45290
- // Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
45283
+ var _b = parsePackageName(moduleName), packageName = _b.packageName, rest = _b.rest;
45284
+ var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45285
+ if (rest !== "") {
45286
+ // Previous `packageInfo` may have been from a nested package.json; ensure we have the one from the package root now.
45291
45287
  packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
45292
- if (packageInfo && packageInfo.contents.versionPaths) {
45293
- if (state.traceEnabled) {
45294
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, ts.version, rest);
45295
- }
45296
- var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45297
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45298
- if (fromPaths) {
45299
- return fromPaths.value;
45300
- }
45288
+ }
45289
+ // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them)
45290
+ if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45291
+ return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45292
+ }
45293
+ if (rest !== "" && packageInfo && packageInfo.contents.versionPaths) {
45294
+ if (state.traceEnabled) {
45295
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, ts.version, rest);
45296
+ }
45297
+ var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45298
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45299
+ if (fromPaths) {
45300
+ return fromPaths.value;
45301
45301
  }
45302
45302
  }
45303
45303
  return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
@@ -55478,6 +55478,7 @@ var ts;
55478
55478
  && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
55479
55479
  && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */)
55480
55480
  && !(symbol.flags & 32 /* SymbolFlags.Class */)
55481
+ && !(symbol.flags & 8192 /* SymbolFlags.Method */)
55481
55482
  && !isConstMergedWithNSPrintableAsSignatureMerge) {
55482
55483
  if (propertyAsAlias) {
55483
55484
  var createdExport = serializeMaybeAliasAssignment(symbol);
@@ -115412,6 +115413,7 @@ var ts;
115412
115413
  writeTrailingSemicolon();
115413
115414
  }
115414
115415
  function emitExportDeclaration(node) {
115416
+ emitModifiers(node, node.modifiers);
115415
115417
  var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
115416
115418
  writeSpace();
115417
115419
  if (node.isTypeOnly) {
@@ -118837,7 +118839,7 @@ var ts;
118837
118839
  * Determines if program structure is upto date or needs to be recreated
118838
118840
  */
118839
118841
  /* @internal */
118840
- function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118842
+ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118841
118843
  // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date
118842
118844
  if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames()))
118843
118845
  return false;
@@ -118865,7 +118867,7 @@ var ts;
118865
118867
  return true;
118866
118868
  function sourceFileNotUptoDate(sourceFile) {
118867
118869
  return !sourceFileVersionUptoDate(sourceFile) ||
118868
- hasInvalidatedResolution(sourceFile.path);
118870
+ hasInvalidatedResolutions(sourceFile.path);
118869
118871
  }
118870
118872
  function sourceFileVersionUptoDate(sourceFile) {
118871
118873
  return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
@@ -119111,7 +119113,7 @@ var ts;
119111
119113
  var moduleResolutionCache;
119112
119114
  var typeReferenceDirectiveResolutionCache;
119113
119115
  var actualResolveModuleNamesWorker;
119114
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
119116
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
119115
119117
  if (host.resolveModuleNames) {
119116
119118
  actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
119117
119119
  // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -119558,7 +119560,7 @@ var ts;
119558
119560
  for (var i = 0; i < moduleNames.length; i++) {
119559
119561
  var moduleName = moduleNames[i];
119560
119562
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
119561
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
119563
+ if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
119562
119564
  var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
119563
119565
  if (oldResolvedModule) {
119564
119566
  if (ts.isTraceEnabled(options, host)) {
@@ -119794,7 +119796,7 @@ var ts;
119794
119796
  // tentatively approve the file
119795
119797
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119796
119798
  }
119797
- else if (hasInvalidatedResolution(oldSourceFile.path)) {
119799
+ else if (hasInvalidatedResolutions(oldSourceFile.path)) {
119798
119800
  // 'module/types' references could have changed
119799
119801
  structureIsReused = 1 /* StructureIsReused.SafeModules */;
119800
119802
  // add file to the modified list so that we will resolve it later
@@ -123840,7 +123842,7 @@ var ts;
123840
123842
  invalidateResolutionOfFile: invalidateResolutionOfFile,
123841
123843
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
123842
123844
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
123843
- createHasInvalidatedResolution: createHasInvalidatedResolution,
123845
+ createHasInvalidatedResolutions: createHasInvalidatedResolutions,
123844
123846
  isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
123845
123847
  updateTypeRootsWatch: updateTypeRootsWatch,
123846
123848
  closeTypeRootsWatch: closeTypeRootsWatch,
@@ -123895,17 +123897,13 @@ var ts;
123895
123897
  var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
123896
123898
  return !!value && !!value.length;
123897
123899
  }
123898
- function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
123900
+ function createHasInvalidatedResolutions(customHasInvalidatedResolutions) {
123899
123901
  // Ensure pending resolutions are applied
123900
123902
  invalidateResolutionsOfFailedLookupLocations();
123901
- if (forceAllFilesAsInvalidated) {
123902
- // Any file asked would have invalidated resolution
123903
- filesWithInvalidatedResolutions = undefined;
123904
- return ts.returnTrue;
123905
- }
123906
123903
  var collected = filesWithInvalidatedResolutions;
123907
123904
  filesWithInvalidatedResolutions = undefined;
123908
- return function (path) { return (!!collected && collected.has(path)) ||
123905
+ return function (path) { return customHasInvalidatedResolutions(path) ||
123906
+ !!(collected === null || collected === void 0 ? void 0 : collected.has(path)) ||
123909
123907
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123910
123908
  }
123911
123909
  function startCachingPerDirectoryResolution() {
@@ -126285,6 +126283,10 @@ var ts;
126285
126283
  ts.maybeBind(host, host.getModuleResolutionCache) :
126286
126284
  (function () { return resolutionCache.getModuleResolutionCache(); });
126287
126285
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
126286
+ // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions
126287
+ var customHasInvalidatedResolutions = userProvidedResolution ?
126288
+ ts.maybeBind(host, host.hasInvalidatedResolutions) || ts.returnTrue :
126289
+ ts.returnFalse;
126288
126290
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
126289
126291
  synchronizeProgram();
126290
126292
  // Update the wild card directory watch
@@ -126350,10 +126352,9 @@ var ts;
126350
126352
  resolutionCache.clear();
126351
126353
  }
126352
126354
  }
126353
- // All resolutions are invalid if user provided resolutions
126354
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
126355
+ var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
126355
126356
  var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
126356
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126357
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126357
126358
  if (hasChangedConfigFileParsingErrors) {
126358
126359
  if (reportFileChangeDetectedOnCreateProgram) {
126359
126360
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -126366,7 +126367,7 @@ var ts;
126366
126367
  if (reportFileChangeDetectedOnCreateProgram) {
126367
126368
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
126368
126369
  }
126369
- createNewProgram(hasInvalidatedResolution);
126370
+ createNewProgram(hasInvalidatedResolutions);
126370
126371
  }
126371
126372
  reportFileChangeDetectedOnCreateProgram = false;
126372
126373
  if (host.afterProgramCreate && program !== builderProgram) {
@@ -126379,7 +126380,7 @@ var ts;
126379
126380
  compilerHost.writeFile = originalWriteFile;
126380
126381
  return builderProgram;
126381
126382
  }
126382
- function createNewProgram(hasInvalidatedResolution) {
126383
+ function createNewProgram(hasInvalidatedResolutions) {
126383
126384
  // Compile the program
126384
126385
  writeLog("CreatingProgramWith::");
126385
126386
  writeLog(" roots: ".concat(JSON.stringify(rootFileNames)));
@@ -126390,7 +126391,7 @@ var ts;
126390
126391
  hasChangedCompilerOptions = false;
126391
126392
  hasChangedConfigFileParsingErrors = false;
126392
126393
  resolutionCache.startCachingPerDirectoryResolution();
126393
- compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
126394
+ compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
126394
126395
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
126395
126396
  var oldProgram = getCurrentProgram();
126396
126397
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
@@ -139593,7 +139594,7 @@ var ts;
139593
139594
  break;
139594
139595
  case 202 /* SyntaxKind.ImportType */:
139595
139596
  // Only check for typeof import('xyz')
139596
- if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139597
+ if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139597
139598
  addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
139598
139599
  }
139599
139600
  directImports.push(direct);
@@ -146759,6 +146760,10 @@ var ts;
146759
146760
  pushSelectionCommentRange(comment.pos, comment.end);
146760
146761
  }
146761
146762
  if (positionShouldSnapToNode(sourceFile, pos, node)) {
146763
+ if (ts.isFunctionBody(node)
146764
+ && ts.isFunctionLikeDeclaration(parentNode) && !ts.positionsAreOnSameLine(node.getStart(sourceFile), node.getEnd(), sourceFile)) {
146765
+ pushSelectionRange(node.getStart(sourceFile), node.getEnd());
146766
+ }
146762
146767
  // 1. Blocks are effectively redundant with SyntaxLists.
146763
146768
  // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
146764
146769
  // of things that should be considered independently.
@@ -158371,7 +158376,7 @@ var ts;
158371
158376
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
158372
158377
  }
158373
158378
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
158374
- if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158379
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158375
158380
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
158376
158381
  }
158377
158382
  return undefined;
@@ -168751,7 +168756,7 @@ var ts;
168751
168756
  var rootFileNames = host.getScriptFileNames().slice();
168752
168757
  // Get a fresh cache of the host information
168753
168758
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
168754
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
168759
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
168755
168760
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
168756
168761
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
168757
168762
  var parsedCommandLines;
@@ -168782,7 +168787,7 @@ var ts;
168782
168787
  },
168783
168788
  onReleaseOldSourceFile: onReleaseOldSourceFile,
168784
168789
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
168785
- hasInvalidatedResolution: hasInvalidatedResolution,
168790
+ hasInvalidatedResolutions: hasInvalidatedResolutions,
168786
168791
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
168787
168792
  trace: ts.maybeBind(host, host.trace),
168788
168793
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
@@ -168822,7 +168827,7 @@ var ts;
168822
168827
  // as a const variable without downleveling, doesn't crash).
168823
168828
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
168824
168829
  // If the program is already up-to-date, we can reuse it
168825
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168830
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168826
168831
  return;
168827
168832
  }
168828
168833
  // IMPORTANT - It is critical from this moment onward that we do not check
@@ -173697,7 +173702,7 @@ var ts;
173697
173702
  ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
173698
173703
  this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName()));
173699
173704
  var start = ts.timestamp();
173700
- this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution();
173705
+ this.hasInvalidatedResolutions = this.resolutionCache.createHasInvalidatedResolutions(ts.returnFalse);
173701
173706
  this.resolutionCache.startCachingPerDirectoryResolution();
173702
173707
  this.program = this.languageService.getProgram(); // TODO: GH#18217
173703
173708
  this.dirty = false;
@@ -3320,6 +3320,8 @@ declare namespace ts {
3320
3320
  */
3321
3321
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
3322
3322
  getEnvironmentVariable?(name: string): string | undefined;
3323
+ /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
3324
+ hasInvalidatedResolutions?(filePath: Path): boolean;
3323
3325
  createHash?(data: string): string;
3324
3326
  getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
3325
3327
  }
@@ -5442,6 +5444,8 @@ declare namespace ts {
5442
5444
  resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
5443
5445
  /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
5444
5446
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
5447
+ /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
5448
+ hasInvalidatedResolutions?(filePath: Path): boolean;
5445
5449
  /**
5446
5450
  * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
5447
5451
  */