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/typescript.js CHANGED
@@ -99,7 +99,7 @@ var ts;
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220921");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220923");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -45243,6 +45243,7 @@ var ts;
45243
45243
  }
45244
45244
  }
45245
45245
  function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
45246
+ var _a;
45246
45247
  var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
45247
45248
  // First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
45248
45249
  var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
@@ -45257,13 +45258,7 @@ var ts;
45257
45258
  return withPackageId(packageInfo, fromDirectory);
45258
45259
  }
45259
45260
  }
45260
- var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
45261
45261
  var loader = function (extensions, candidate, onlyRecordFailures, state) {
45262
- var _a;
45263
- // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
45264
- if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45265
- return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45266
- }
45267
45262
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
45268
45263
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.contents.packageJsonContent, packageInfo && packageInfo.contents.versionPaths);
45269
45264
  if (!pathAndExtension && packageInfo
@@ -45276,19 +45271,24 @@ var ts;
45276
45271
  }
45277
45272
  return withPackageId(packageInfo, pathAndExtension);
45278
45273
  };
45279
- if (rest !== "") { // If "rest" is empty, we just did this search above.
45280
- var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45281
- // 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.
45274
+ var _b = parsePackageName(moduleName), packageName = _b.packageName, rest = _b.rest;
45275
+ var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45276
+ if (rest !== "") {
45277
+ // Previous `packageInfo` may have been from a nested package.json; ensure we have the one from the package root now.
45282
45278
  packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
45283
- if (packageInfo && packageInfo.contents.versionPaths) {
45284
- if (state.traceEnabled) {
45285
- 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);
45286
- }
45287
- var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45288
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45289
- if (fromPaths) {
45290
- return fromPaths.value;
45291
- }
45279
+ }
45280
+ // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them)
45281
+ if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45282
+ return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45283
+ }
45284
+ if (rest !== "" && packageInfo && packageInfo.contents.versionPaths) {
45285
+ if (state.traceEnabled) {
45286
+ 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);
45287
+ }
45288
+ var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45289
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45290
+ if (fromPaths) {
45291
+ return fromPaths.value;
45292
45292
  }
45293
45293
  }
45294
45294
  return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
@@ -55469,6 +55469,7 @@ var ts;
55469
55469
  && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
55470
55470
  && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */)
55471
55471
  && !(symbol.flags & 32 /* SymbolFlags.Class */)
55472
+ && !(symbol.flags & 8192 /* SymbolFlags.Method */)
55472
55473
  && !isConstMergedWithNSPrintableAsSignatureMerge) {
55473
55474
  if (propertyAsAlias) {
55474
55475
  var createdExport = serializeMaybeAliasAssignment(symbol);
@@ -115403,6 +115404,7 @@ var ts;
115403
115404
  writeTrailingSemicolon();
115404
115405
  }
115405
115406
  function emitExportDeclaration(node) {
115407
+ emitModifiers(node, node.modifiers);
115406
115408
  var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
115407
115409
  writeSpace();
115408
115410
  if (node.isTypeOnly) {
@@ -118828,7 +118830,7 @@ var ts;
118828
118830
  * Determines if program structure is upto date or needs to be recreated
118829
118831
  */
118830
118832
  /* @internal */
118831
- function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118833
+ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118832
118834
  // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date
118833
118835
  if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames()))
118834
118836
  return false;
@@ -118856,7 +118858,7 @@ var ts;
118856
118858
  return true;
118857
118859
  function sourceFileNotUptoDate(sourceFile) {
118858
118860
  return !sourceFileVersionUptoDate(sourceFile) ||
118859
- hasInvalidatedResolution(sourceFile.path);
118861
+ hasInvalidatedResolutions(sourceFile.path);
118860
118862
  }
118861
118863
  function sourceFileVersionUptoDate(sourceFile) {
118862
118864
  return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
@@ -119102,7 +119104,7 @@ var ts;
119102
119104
  var moduleResolutionCache;
119103
119105
  var typeReferenceDirectiveResolutionCache;
119104
119106
  var actualResolveModuleNamesWorker;
119105
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
119107
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
119106
119108
  if (host.resolveModuleNames) {
119107
119109
  actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
119108
119110
  // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -119549,7 +119551,7 @@ var ts;
119549
119551
  for (var i = 0; i < moduleNames.length; i++) {
119550
119552
  var moduleName = moduleNames[i];
119551
119553
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
119552
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
119554
+ if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
119553
119555
  var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
119554
119556
  if (oldResolvedModule) {
119555
119557
  if (ts.isTraceEnabled(options, host)) {
@@ -119785,7 +119787,7 @@ var ts;
119785
119787
  // tentatively approve the file
119786
119788
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119787
119789
  }
119788
- else if (hasInvalidatedResolution(oldSourceFile.path)) {
119790
+ else if (hasInvalidatedResolutions(oldSourceFile.path)) {
119789
119791
  // 'module/types' references could have changed
119790
119792
  structureIsReused = 1 /* StructureIsReused.SafeModules */;
119791
119793
  // add file to the modified list so that we will resolve it later
@@ -123831,7 +123833,7 @@ var ts;
123831
123833
  invalidateResolutionOfFile: invalidateResolutionOfFile,
123832
123834
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
123833
123835
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
123834
- createHasInvalidatedResolution: createHasInvalidatedResolution,
123836
+ createHasInvalidatedResolutions: createHasInvalidatedResolutions,
123835
123837
  isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
123836
123838
  updateTypeRootsWatch: updateTypeRootsWatch,
123837
123839
  closeTypeRootsWatch: closeTypeRootsWatch,
@@ -123886,17 +123888,13 @@ var ts;
123886
123888
  var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
123887
123889
  return !!value && !!value.length;
123888
123890
  }
123889
- function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
123891
+ function createHasInvalidatedResolutions(customHasInvalidatedResolutions) {
123890
123892
  // Ensure pending resolutions are applied
123891
123893
  invalidateResolutionsOfFailedLookupLocations();
123892
- if (forceAllFilesAsInvalidated) {
123893
- // Any file asked would have invalidated resolution
123894
- filesWithInvalidatedResolutions = undefined;
123895
- return ts.returnTrue;
123896
- }
123897
123894
  var collected = filesWithInvalidatedResolutions;
123898
123895
  filesWithInvalidatedResolutions = undefined;
123899
- return function (path) { return (!!collected && collected.has(path)) ||
123896
+ return function (path) { return customHasInvalidatedResolutions(path) ||
123897
+ !!(collected === null || collected === void 0 ? void 0 : collected.has(path)) ||
123900
123898
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123901
123899
  }
123902
123900
  function startCachingPerDirectoryResolution() {
@@ -126276,6 +126274,10 @@ var ts;
126276
126274
  ts.maybeBind(host, host.getModuleResolutionCache) :
126277
126275
  (function () { return resolutionCache.getModuleResolutionCache(); });
126278
126276
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
126277
+ // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions
126278
+ var customHasInvalidatedResolutions = userProvidedResolution ?
126279
+ ts.maybeBind(host, host.hasInvalidatedResolutions) || ts.returnTrue :
126280
+ ts.returnFalse;
126279
126281
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
126280
126282
  synchronizeProgram();
126281
126283
  // Update the wild card directory watch
@@ -126341,10 +126343,9 @@ var ts;
126341
126343
  resolutionCache.clear();
126342
126344
  }
126343
126345
  }
126344
- // All resolutions are invalid if user provided resolutions
126345
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
126346
+ var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
126346
126347
  var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
126347
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126348
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126348
126349
  if (hasChangedConfigFileParsingErrors) {
126349
126350
  if (reportFileChangeDetectedOnCreateProgram) {
126350
126351
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -126357,7 +126358,7 @@ var ts;
126357
126358
  if (reportFileChangeDetectedOnCreateProgram) {
126358
126359
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
126359
126360
  }
126360
- createNewProgram(hasInvalidatedResolution);
126361
+ createNewProgram(hasInvalidatedResolutions);
126361
126362
  }
126362
126363
  reportFileChangeDetectedOnCreateProgram = false;
126363
126364
  if (host.afterProgramCreate && program !== builderProgram) {
@@ -126370,7 +126371,7 @@ var ts;
126370
126371
  compilerHost.writeFile = originalWriteFile;
126371
126372
  return builderProgram;
126372
126373
  }
126373
- function createNewProgram(hasInvalidatedResolution) {
126374
+ function createNewProgram(hasInvalidatedResolutions) {
126374
126375
  // Compile the program
126375
126376
  writeLog("CreatingProgramWith::");
126376
126377
  writeLog(" roots: ".concat(JSON.stringify(rootFileNames)));
@@ -126381,7 +126382,7 @@ var ts;
126381
126382
  hasChangedCompilerOptions = false;
126382
126383
  hasChangedConfigFileParsingErrors = false;
126383
126384
  resolutionCache.startCachingPerDirectoryResolution();
126384
- compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
126385
+ compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
126385
126386
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
126386
126387
  var oldProgram = getCurrentProgram();
126387
126388
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
@@ -139584,7 +139585,7 @@ var ts;
139584
139585
  break;
139585
139586
  case 202 /* SyntaxKind.ImportType */:
139586
139587
  // Only check for typeof import('xyz')
139587
- if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139588
+ if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139588
139589
  addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
139589
139590
  }
139590
139591
  directImports.push(direct);
@@ -146750,6 +146751,10 @@ var ts;
146750
146751
  pushSelectionCommentRange(comment.pos, comment.end);
146751
146752
  }
146752
146753
  if (positionShouldSnapToNode(sourceFile, pos, node)) {
146754
+ if (ts.isFunctionBody(node)
146755
+ && ts.isFunctionLikeDeclaration(parentNode) && !ts.positionsAreOnSameLine(node.getStart(sourceFile), node.getEnd(), sourceFile)) {
146756
+ pushSelectionRange(node.getStart(sourceFile), node.getEnd());
146757
+ }
146753
146758
  // 1. Blocks are effectively redundant with SyntaxLists.
146754
146759
  // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
146755
146760
  // of things that should be considered independently.
@@ -158362,7 +158367,7 @@ var ts;
158362
158367
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
158363
158368
  }
158364
158369
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
158365
- if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158370
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158366
158371
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
158367
158372
  }
158368
158373
  return undefined;
@@ -168742,7 +168747,7 @@ var ts;
168742
168747
  var rootFileNames = host.getScriptFileNames().slice();
168743
168748
  // Get a fresh cache of the host information
168744
168749
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
168745
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
168750
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
168746
168751
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
168747
168752
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
168748
168753
  var parsedCommandLines;
@@ -168773,7 +168778,7 @@ var ts;
168773
168778
  },
168774
168779
  onReleaseOldSourceFile: onReleaseOldSourceFile,
168775
168780
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
168776
- hasInvalidatedResolution: hasInvalidatedResolution,
168781
+ hasInvalidatedResolutions: hasInvalidatedResolutions,
168777
168782
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
168778
168783
  trace: ts.maybeBind(host, host.trace),
168779
168784
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
@@ -168813,7 +168818,7 @@ var ts;
168813
168818
  // as a const variable without downleveling, doesn't crash).
168814
168819
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
168815
168820
  // If the program is already up-to-date, we can reuse it
168816
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168821
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168817
168822
  return;
168818
168823
  }
168819
168824
  // IMPORTANT - It is critical from this moment onward that we do not check
@@ -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
  */
@@ -99,7 +99,7 @@ var ts;
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220921");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220923");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -45243,6 +45243,7 @@ var ts;
45243
45243
  }
45244
45244
  }
45245
45245
  function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
45246
+ var _a;
45246
45247
  var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
45247
45248
  // First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
45248
45249
  var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
@@ -45257,13 +45258,7 @@ var ts;
45257
45258
  return withPackageId(packageInfo, fromDirectory);
45258
45259
  }
45259
45260
  }
45260
- var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
45261
45261
  var loader = function (extensions, candidate, onlyRecordFailures, state) {
45262
- var _a;
45263
- // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
45264
- if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45265
- return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45266
- }
45267
45262
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
45268
45263
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.contents.packageJsonContent, packageInfo && packageInfo.contents.versionPaths);
45269
45264
  if (!pathAndExtension && packageInfo
@@ -45276,19 +45271,24 @@ var ts;
45276
45271
  }
45277
45272
  return withPackageId(packageInfo, pathAndExtension);
45278
45273
  };
45279
- if (rest !== "") { // If "rest" is empty, we just did this search above.
45280
- var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45281
- // 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.
45274
+ var _b = parsePackageName(moduleName), packageName = _b.packageName, rest = _b.rest;
45275
+ var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45276
+ if (rest !== "") {
45277
+ // Previous `packageInfo` may have been from a nested package.json; ensure we have the one from the package root now.
45282
45278
  packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
45283
- if (packageInfo && packageInfo.contents.versionPaths) {
45284
- if (state.traceEnabled) {
45285
- 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);
45286
- }
45287
- var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45288
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45289
- if (fromPaths) {
45290
- return fromPaths.value;
45291
- }
45279
+ }
45280
+ // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them)
45281
+ if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45282
+ return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45283
+ }
45284
+ if (rest !== "" && packageInfo && packageInfo.contents.versionPaths) {
45285
+ if (state.traceEnabled) {
45286
+ 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);
45287
+ }
45288
+ var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45289
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45290
+ if (fromPaths) {
45291
+ return fromPaths.value;
45292
45292
  }
45293
45293
  }
45294
45294
  return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
@@ -55469,6 +55469,7 @@ var ts;
55469
55469
  && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
55470
55470
  && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */)
55471
55471
  && !(symbol.flags & 32 /* SymbolFlags.Class */)
55472
+ && !(symbol.flags & 8192 /* SymbolFlags.Method */)
55472
55473
  && !isConstMergedWithNSPrintableAsSignatureMerge) {
55473
55474
  if (propertyAsAlias) {
55474
55475
  var createdExport = serializeMaybeAliasAssignment(symbol);
@@ -115403,6 +115404,7 @@ var ts;
115403
115404
  writeTrailingSemicolon();
115404
115405
  }
115405
115406
  function emitExportDeclaration(node) {
115407
+ emitModifiers(node, node.modifiers);
115406
115408
  var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
115407
115409
  writeSpace();
115408
115410
  if (node.isTypeOnly) {
@@ -118828,7 +118830,7 @@ var ts;
118828
118830
  * Determines if program structure is upto date or needs to be recreated
118829
118831
  */
118830
118832
  /* @internal */
118831
- function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118833
+ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118832
118834
  // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date
118833
118835
  if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames()))
118834
118836
  return false;
@@ -118856,7 +118858,7 @@ var ts;
118856
118858
  return true;
118857
118859
  function sourceFileNotUptoDate(sourceFile) {
118858
118860
  return !sourceFileVersionUptoDate(sourceFile) ||
118859
- hasInvalidatedResolution(sourceFile.path);
118861
+ hasInvalidatedResolutions(sourceFile.path);
118860
118862
  }
118861
118863
  function sourceFileVersionUptoDate(sourceFile) {
118862
118864
  return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
@@ -119102,7 +119104,7 @@ var ts;
119102
119104
  var moduleResolutionCache;
119103
119105
  var typeReferenceDirectiveResolutionCache;
119104
119106
  var actualResolveModuleNamesWorker;
119105
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
119107
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
119106
119108
  if (host.resolveModuleNames) {
119107
119109
  actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
119108
119110
  // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -119549,7 +119551,7 @@ var ts;
119549
119551
  for (var i = 0; i < moduleNames.length; i++) {
119550
119552
  var moduleName = moduleNames[i];
119551
119553
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
119552
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
119554
+ if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
119553
119555
  var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
119554
119556
  if (oldResolvedModule) {
119555
119557
  if (ts.isTraceEnabled(options, host)) {
@@ -119785,7 +119787,7 @@ var ts;
119785
119787
  // tentatively approve the file
119786
119788
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119787
119789
  }
119788
- else if (hasInvalidatedResolution(oldSourceFile.path)) {
119790
+ else if (hasInvalidatedResolutions(oldSourceFile.path)) {
119789
119791
  // 'module/types' references could have changed
119790
119792
  structureIsReused = 1 /* StructureIsReused.SafeModules */;
119791
119793
  // add file to the modified list so that we will resolve it later
@@ -123831,7 +123833,7 @@ var ts;
123831
123833
  invalidateResolutionOfFile: invalidateResolutionOfFile,
123832
123834
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
123833
123835
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
123834
- createHasInvalidatedResolution: createHasInvalidatedResolution,
123836
+ createHasInvalidatedResolutions: createHasInvalidatedResolutions,
123835
123837
  isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
123836
123838
  updateTypeRootsWatch: updateTypeRootsWatch,
123837
123839
  closeTypeRootsWatch: closeTypeRootsWatch,
@@ -123886,17 +123888,13 @@ var ts;
123886
123888
  var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
123887
123889
  return !!value && !!value.length;
123888
123890
  }
123889
- function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
123891
+ function createHasInvalidatedResolutions(customHasInvalidatedResolutions) {
123890
123892
  // Ensure pending resolutions are applied
123891
123893
  invalidateResolutionsOfFailedLookupLocations();
123892
- if (forceAllFilesAsInvalidated) {
123893
- // Any file asked would have invalidated resolution
123894
- filesWithInvalidatedResolutions = undefined;
123895
- return ts.returnTrue;
123896
- }
123897
123894
  var collected = filesWithInvalidatedResolutions;
123898
123895
  filesWithInvalidatedResolutions = undefined;
123899
- return function (path) { return (!!collected && collected.has(path)) ||
123896
+ return function (path) { return customHasInvalidatedResolutions(path) ||
123897
+ !!(collected === null || collected === void 0 ? void 0 : collected.has(path)) ||
123900
123898
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123901
123899
  }
123902
123900
  function startCachingPerDirectoryResolution() {
@@ -126276,6 +126274,10 @@ var ts;
126276
126274
  ts.maybeBind(host, host.getModuleResolutionCache) :
126277
126275
  (function () { return resolutionCache.getModuleResolutionCache(); });
126278
126276
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
126277
+ // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions
126278
+ var customHasInvalidatedResolutions = userProvidedResolution ?
126279
+ ts.maybeBind(host, host.hasInvalidatedResolutions) || ts.returnTrue :
126280
+ ts.returnFalse;
126279
126281
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
126280
126282
  synchronizeProgram();
126281
126283
  // Update the wild card directory watch
@@ -126341,10 +126343,9 @@ var ts;
126341
126343
  resolutionCache.clear();
126342
126344
  }
126343
126345
  }
126344
- // All resolutions are invalid if user provided resolutions
126345
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
126346
+ var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
126346
126347
  var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
126347
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126348
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126348
126349
  if (hasChangedConfigFileParsingErrors) {
126349
126350
  if (reportFileChangeDetectedOnCreateProgram) {
126350
126351
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -126357,7 +126358,7 @@ var ts;
126357
126358
  if (reportFileChangeDetectedOnCreateProgram) {
126358
126359
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
126359
126360
  }
126360
- createNewProgram(hasInvalidatedResolution);
126361
+ createNewProgram(hasInvalidatedResolutions);
126361
126362
  }
126362
126363
  reportFileChangeDetectedOnCreateProgram = false;
126363
126364
  if (host.afterProgramCreate && program !== builderProgram) {
@@ -126370,7 +126371,7 @@ var ts;
126370
126371
  compilerHost.writeFile = originalWriteFile;
126371
126372
  return builderProgram;
126372
126373
  }
126373
- function createNewProgram(hasInvalidatedResolution) {
126374
+ function createNewProgram(hasInvalidatedResolutions) {
126374
126375
  // Compile the program
126375
126376
  writeLog("CreatingProgramWith::");
126376
126377
  writeLog(" roots: ".concat(JSON.stringify(rootFileNames)));
@@ -126381,7 +126382,7 @@ var ts;
126381
126382
  hasChangedCompilerOptions = false;
126382
126383
  hasChangedConfigFileParsingErrors = false;
126383
126384
  resolutionCache.startCachingPerDirectoryResolution();
126384
- compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
126385
+ compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
126385
126386
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
126386
126387
  var oldProgram = getCurrentProgram();
126387
126388
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
@@ -139584,7 +139585,7 @@ var ts;
139584
139585
  break;
139585
139586
  case 202 /* SyntaxKind.ImportType */:
139586
139587
  // Only check for typeof import('xyz')
139587
- if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139588
+ if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139588
139589
  addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
139589
139590
  }
139590
139591
  directImports.push(direct);
@@ -146750,6 +146751,10 @@ var ts;
146750
146751
  pushSelectionCommentRange(comment.pos, comment.end);
146751
146752
  }
146752
146753
  if (positionShouldSnapToNode(sourceFile, pos, node)) {
146754
+ if (ts.isFunctionBody(node)
146755
+ && ts.isFunctionLikeDeclaration(parentNode) && !ts.positionsAreOnSameLine(node.getStart(sourceFile), node.getEnd(), sourceFile)) {
146756
+ pushSelectionRange(node.getStart(sourceFile), node.getEnd());
146757
+ }
146753
146758
  // 1. Blocks are effectively redundant with SyntaxLists.
146754
146759
  // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
146755
146760
  // of things that should be considered independently.
@@ -158362,7 +158367,7 @@ var ts;
158362
158367
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
158363
158368
  }
158364
158369
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
158365
- if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158370
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158366
158371
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
158367
158372
  }
158368
158373
  return undefined;
@@ -168742,7 +168747,7 @@ var ts;
168742
168747
  var rootFileNames = host.getScriptFileNames().slice();
168743
168748
  // Get a fresh cache of the host information
168744
168749
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
168745
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
168750
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
168746
168751
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
168747
168752
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
168748
168753
  var parsedCommandLines;
@@ -168773,7 +168778,7 @@ var ts;
168773
168778
  },
168774
168779
  onReleaseOldSourceFile: onReleaseOldSourceFile,
168775
168780
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
168776
- hasInvalidatedResolution: hasInvalidatedResolution,
168781
+ hasInvalidatedResolutions: hasInvalidatedResolutions,
168777
168782
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
168778
168783
  trace: ts.maybeBind(host, host.trace),
168779
168784
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
@@ -168813,7 +168818,7 @@ var ts;
168813
168818
  // as a const variable without downleveling, doesn't crash).
168814
168819
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
168815
168820
  // If the program is already up-to-date, we can reuse it
168816
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168821
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168817
168822
  return;
168818
168823
  }
168819
168824
  // IMPORTANT - It is critical from this moment onward that we do not check