typescript 5.6.0-dev.20240712 → 5.6.0-dev.20240714

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/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.6";
21
- var version = `${versionMajorMinor}.0-dev.20240712`;
21
+ var version = `${versionMajorMinor}.0-dev.20240714`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6999,7 +6999,6 @@ var Diagnostics = {
6999
6999
  Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, 3 /* Message */, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", 'Parse in strict mode and emit "use strict" for each source file.'),
7000
7000
  Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, 1 /* Error */, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."),
7001
7001
  Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, 3 /* Message */, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."),
7002
- Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, 3 /* Message */, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."),
7003
7002
  Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, 3 /* Message */, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."),
7004
7003
  Resolution_for_module_0_was_found_in_cache_from_location_1: diag(6147, 3 /* Message */, "Resolution_for_module_0_was_found_in_cache_from_location_1_6147", "Resolution for module '{0}' was found in cache from location '{1}'."),
7005
7004
  Directory_0_does_not_exist_skipping_all_lookups_in_it: diag(6148, 3 /* Message */, "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", "Directory '{0}' does not exist, skipping all lookups in it."),
@@ -45519,13 +45518,6 @@ function createTypeChecker(host) {
45519
45518
  /*withAugmentations*/
45520
45519
  true
45521
45520
  ),
45522
- tryFindAmbientModuleWithoutAugmentations: (moduleName) => {
45523
- return tryFindAmbientModule(
45524
- moduleName,
45525
- /*withAugmentations*/
45526
- false
45527
- );
45528
- },
45529
45521
  getApparentType,
45530
45522
  getUnionType,
45531
45523
  isTypeAssignableTo,
@@ -46068,6 +46060,7 @@ function createTypeChecker(host) {
46068
46060
  };
46069
46061
  var amalgamatedDuplicates;
46070
46062
  var reverseMappedCache = /* @__PURE__ */ new Map();
46063
+ var reverseHomomorphicMappedCache = /* @__PURE__ */ new Map();
46071
46064
  var ambientModulesCache;
46072
46065
  var patternAmbientModules;
46073
46066
  var patternAmbientModuleAugmentations;
@@ -50296,7 +50289,21 @@ function createTypeChecker(host) {
50296
50289
  }
50297
50290
  function shouldUsePlaceholderForProperty(propertySymbol, context) {
50298
50291
  var _a;
50299
- return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
50292
+ const depth = 3;
50293
+ return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */) || isDeeplyNestedReverseMappedTypeProperty());
50294
+ function isDeeplyNestedReverseMappedTypeProperty() {
50295
+ var _a2;
50296
+ if ((((_a2 = context.reverseMappedStack) == null ? void 0 : _a2.length) ?? 0) < depth) {
50297
+ return false;
50298
+ }
50299
+ for (let i = 0; i < depth; i++) {
50300
+ const prop = context.reverseMappedStack[context.reverseMappedStack.length - 1 - i];
50301
+ if (prop.links.mappedType.symbol !== propertySymbol.links.mappedType.symbol) {
50302
+ return false;
50303
+ }
50304
+ }
50305
+ return true;
50306
+ }
50300
50307
  }
50301
50308
  function addPropertyToElementList(propertySymbol, context, typeElements) {
50302
50309
  var _a;
@@ -66342,11 +66349,11 @@ function createTypeChecker(host) {
66342
66349
  }
66343
66350
  function inferTypeForHomomorphicMappedType(source, target, constraint) {
66344
66351
  const cacheKey = source.id + "," + target.id + "," + constraint.id;
66345
- if (reverseMappedCache.has(cacheKey)) {
66346
- return reverseMappedCache.get(cacheKey);
66352
+ if (reverseHomomorphicMappedCache.has(cacheKey)) {
66353
+ return reverseHomomorphicMappedCache.get(cacheKey);
66347
66354
  }
66348
66355
  const type = createReverseMappedType(source, target, constraint);
66349
- reverseMappedCache.set(cacheKey, type);
66356
+ reverseHomomorphicMappedCache.set(cacheKey, type);
66350
66357
  return type;
66351
66358
  }
66352
66359
  function isPartiallyInferableType(type) {
@@ -119258,7 +119265,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119258
119265
  let commonSourceDirectory;
119259
119266
  let typeChecker;
119260
119267
  let classifiableNames;
119261
- const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
119262
119268
  let fileReasons = createMultiMap();
119263
119269
  let filesWithReferencesProcessed;
119264
119270
  let fileReasonsToChain;
@@ -119848,35 +119854,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119848
119854
  getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
119849
119855
  getResolved: getResolvedModuleFromResolution,
119850
119856
  canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
119851
- isEntryResolvingToAmbientModule: moduleNameResolvesToAmbientModule
119857
+ resolveToOwnAmbientModule: true
119852
119858
  });
119853
119859
  }
119854
- function moduleNameResolvesToAmbientModule(moduleName, file) {
119855
- if (contains(file.ambientModuleNames, moduleName.text)) {
119856
- if (isTraceEnabled(options, host)) {
119857
- trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
119858
- }
119859
- return true;
119860
- } else {
119861
- return moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file);
119862
- }
119863
- }
119864
- function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file) {
119865
- var _a2;
119866
- const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName))) == null ? void 0 : _a2.resolvedModule;
119867
- const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
119868
- if (resolutionToFile && resolvedFile) {
119869
- return false;
119870
- }
119871
- const unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName.text);
119872
- if (!unmodifiedFile) {
119873
- return false;
119874
- }
119875
- if (isTraceEnabled(options, host)) {
119876
- trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName.text, unmodifiedFile);
119877
- }
119878
- return true;
119879
- }
119880
119860
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
119881
119861
  const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119882
119862
  return resolveNamesReusingOldState({
@@ -119904,10 +119884,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119904
119884
  getResolutionFromOldProgram,
119905
119885
  getResolved,
119906
119886
  canReuseResolutionsInFile,
119907
- isEntryResolvingToAmbientModule
119887
+ resolveToOwnAmbientModule
119908
119888
  }) {
119909
119889
  if (!entries.length) return emptyArray;
119910
- if (structureIsReused === 0 /* Not */ && (!isEntryResolvingToAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
119890
+ if (structureIsReused === 0 /* Not */ && (!resolveToOwnAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
119911
119891
  return resolutionWorker(
119912
119892
  entries,
119913
119893
  containingFile,
@@ -119943,12 +119923,23 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119943
119923
  continue;
119944
119924
  }
119945
119925
  }
119946
- if (isEntryResolvingToAmbientModule == null ? void 0 : isEntryResolvingToAmbientModule(entry, containingFile)) {
119947
- (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
119948
- } else {
119949
- (unknownEntries ?? (unknownEntries = [])).push(entry);
119950
- (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
119926
+ if (resolveToOwnAmbientModule) {
119927
+ const name = nameAndModeGetter.getName(entry);
119928
+ if (contains(containingSourceFile.ambientModuleNames, name)) {
119929
+ if (isTraceEnabled(options, host)) {
119930
+ trace(
119931
+ host,
119932
+ Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1,
119933
+ name,
119934
+ getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory)
119935
+ );
119936
+ }
119937
+ (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
119938
+ continue;
119939
+ }
119951
119940
  }
119941
+ (unknownEntries ?? (unknownEntries = [])).push(entry);
119942
+ (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
119952
119943
  }
119953
119944
  if (!unknownEntries) return result;
119954
119945
  const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
@@ -120082,10 +120073,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120082
120073
  } else if (hasInvalidatedResolutions(oldSourceFile.path)) {
120083
120074
  structureIsReused = 1 /* SafeModules */;
120084
120075
  modifiedSourceFiles.push(newSourceFile);
120085
- } else {
120086
- for (const moduleName of oldSourceFile.ambientModuleNames) {
120087
- ambientModuleNameToUnmodifiedFileName.set(moduleName, oldSourceFile.fileName);
120088
- }
120089
120076
  }
120090
120077
  newSourceFiles.push(newSourceFile);
120091
120078
  }
@@ -124613,7 +124600,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124613
124600
  let filesWithChangedSetOfUnresolvedImports;
124614
124601
  let filesWithInvalidatedResolutions;
124615
124602
  let filesWithInvalidatedNonRelativeUnresolvedImports;
124616
- const nonRelativeExternalModuleResolutions = createMultiMap();
124603
+ const nonRelativeExternalModuleResolutions = /* @__PURE__ */ new Set();
124617
124604
  const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
124618
124605
  const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
124619
124606
  const resolvedFileToResolution = /* @__PURE__ */ new Map();
@@ -124764,8 +124751,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124764
124751
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
124765
124752
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
124766
124753
  libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
124767
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
124768
- nonRelativeExternalModuleResolutions.clear();
124754
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
124769
124755
  isSymlinkCache.clear();
124770
124756
  }
124771
124757
  function cleanupLibResolutionWatching(newProgram) {
@@ -124784,8 +124770,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124784
124770
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
124785
124771
  filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
124786
124772
  allModuleAndTypeResolutionsAreInvalidated = false;
124787
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
124788
- nonRelativeExternalModuleResolutions.clear();
124773
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
124789
124774
  if (newProgram !== oldProgram) {
124790
124775
  cleanupLibResolutionWatching(newProgram);
124791
124776
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
@@ -125048,7 +125033,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125048
125033
  if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
125049
125034
  watchFailedLookupLocationOfResolution(resolution);
125050
125035
  } else {
125051
- nonRelativeExternalModuleResolutions.add(name, resolution);
125036
+ nonRelativeExternalModuleResolutions.add(resolution);
125052
125037
  }
125053
125038
  const resolved = getResolutionWithResolvedFileName(resolution);
125054
125039
  if (resolved && resolved.resolvedFileName) {
@@ -125184,17 +125169,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125184
125169
  (_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path2) => invalidateAffectingFileWatcher(path2, packageJsonMap));
125185
125170
  packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
125186
125171
  }
125187
- function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
125188
- const program = resolutionHost.getCurrentProgram();
125189
- if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
125190
- resolutions.forEach(watchFailedLookupLocationOfResolution);
125191
- } else {
125192
- resolutions.forEach((resolution) => watchAffectingLocationsOfResolution(
125193
- resolution,
125194
- /*addToResolutionsWithOnlyAffectingLocations*/
125195
- true
125196
- ));
125197
- }
125172
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
125173
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
125174
+ nonRelativeExternalModuleResolutions.clear();
125198
125175
  }
125199
125176
  function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
125200
125177
  Debug.assert(!nonRecursive);
package/lib/typescript.js CHANGED
@@ -2251,7 +2251,7 @@ module.exports = __toCommonJS(typescript_exports);
2251
2251
 
2252
2252
  // src/compiler/corePublic.ts
2253
2253
  var versionMajorMinor = "5.6";
2254
- var version = `${versionMajorMinor}.0-dev.20240712`;
2254
+ var version = `${versionMajorMinor}.0-dev.20240714`;
2255
2255
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2256
2256
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2257
2257
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -10379,7 +10379,6 @@ var Diagnostics = {
10379
10379
  Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, 3 /* Message */, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", 'Parse in strict mode and emit "use strict" for each source file.'),
10380
10380
  Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, 1 /* Error */, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."),
10381
10381
  Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, 3 /* Message */, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."),
10382
- Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, 3 /* Message */, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."),
10383
10382
  Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, 3 /* Message */, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."),
10384
10383
  Resolution_for_module_0_was_found_in_cache_from_location_1: diag(6147, 3 /* Message */, "Resolution_for_module_0_was_found_in_cache_from_location_1_6147", "Resolution for module '{0}' was found in cache from location '{1}'."),
10385
10384
  Directory_0_does_not_exist_skipping_all_lookups_in_it: diag(6148, 3 /* Message */, "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", "Directory '{0}' does not exist, skipping all lookups in it."),
@@ -50121,13 +50120,6 @@ function createTypeChecker(host) {
50121
50120
  /*withAugmentations*/
50122
50121
  true
50123
50122
  ),
50124
- tryFindAmbientModuleWithoutAugmentations: (moduleName) => {
50125
- return tryFindAmbientModule(
50126
- moduleName,
50127
- /*withAugmentations*/
50128
- false
50129
- );
50130
- },
50131
50123
  getApparentType,
50132
50124
  getUnionType,
50133
50125
  isTypeAssignableTo,
@@ -50670,6 +50662,7 @@ function createTypeChecker(host) {
50670
50662
  };
50671
50663
  var amalgamatedDuplicates;
50672
50664
  var reverseMappedCache = /* @__PURE__ */ new Map();
50665
+ var reverseHomomorphicMappedCache = /* @__PURE__ */ new Map();
50673
50666
  var ambientModulesCache;
50674
50667
  var patternAmbientModules;
50675
50668
  var patternAmbientModuleAugmentations;
@@ -54898,7 +54891,21 @@ function createTypeChecker(host) {
54898
54891
  }
54899
54892
  function shouldUsePlaceholderForProperty(propertySymbol, context) {
54900
54893
  var _a;
54901
- return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
54894
+ const depth = 3;
54895
+ return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */) || isDeeplyNestedReverseMappedTypeProperty());
54896
+ function isDeeplyNestedReverseMappedTypeProperty() {
54897
+ var _a2;
54898
+ if ((((_a2 = context.reverseMappedStack) == null ? void 0 : _a2.length) ?? 0) < depth) {
54899
+ return false;
54900
+ }
54901
+ for (let i = 0; i < depth; i++) {
54902
+ const prop = context.reverseMappedStack[context.reverseMappedStack.length - 1 - i];
54903
+ if (prop.links.mappedType.symbol !== propertySymbol.links.mappedType.symbol) {
54904
+ return false;
54905
+ }
54906
+ }
54907
+ return true;
54908
+ }
54902
54909
  }
54903
54910
  function addPropertyToElementList(propertySymbol, context, typeElements) {
54904
54911
  var _a;
@@ -70944,11 +70951,11 @@ function createTypeChecker(host) {
70944
70951
  }
70945
70952
  function inferTypeForHomomorphicMappedType(source, target, constraint) {
70946
70953
  const cacheKey = source.id + "," + target.id + "," + constraint.id;
70947
- if (reverseMappedCache.has(cacheKey)) {
70948
- return reverseMappedCache.get(cacheKey);
70954
+ if (reverseHomomorphicMappedCache.has(cacheKey)) {
70955
+ return reverseHomomorphicMappedCache.get(cacheKey);
70949
70956
  }
70950
70957
  const type = createReverseMappedType(source, target, constraint);
70951
- reverseMappedCache.set(cacheKey, type);
70958
+ reverseHomomorphicMappedCache.set(cacheKey, type);
70952
70959
  return type;
70953
70960
  }
70954
70961
  function isPartiallyInferableType(type) {
@@ -124096,7 +124103,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124096
124103
  let commonSourceDirectory;
124097
124104
  let typeChecker;
124098
124105
  let classifiableNames;
124099
- const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
124100
124106
  let fileReasons = createMultiMap();
124101
124107
  let filesWithReferencesProcessed;
124102
124108
  let fileReasonsToChain;
@@ -124686,35 +124692,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124686
124692
  getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
124687
124693
  getResolved: getResolvedModuleFromResolution,
124688
124694
  canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
124689
- isEntryResolvingToAmbientModule: moduleNameResolvesToAmbientModule
124695
+ resolveToOwnAmbientModule: true
124690
124696
  });
124691
124697
  }
124692
- function moduleNameResolvesToAmbientModule(moduleName, file) {
124693
- if (contains(file.ambientModuleNames, moduleName.text)) {
124694
- if (isTraceEnabled(options, host)) {
124695
- trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
124696
- }
124697
- return true;
124698
- } else {
124699
- return moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file);
124700
- }
124701
- }
124702
- function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file) {
124703
- var _a2;
124704
- const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName))) == null ? void 0 : _a2.resolvedModule;
124705
- const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
124706
- if (resolutionToFile && resolvedFile) {
124707
- return false;
124708
- }
124709
- const unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName.text);
124710
- if (!unmodifiedFile) {
124711
- return false;
124712
- }
124713
- if (isTraceEnabled(options, host)) {
124714
- trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName.text, unmodifiedFile);
124715
- }
124716
- return true;
124717
- }
124718
124698
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
124719
124699
  const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
124720
124700
  return resolveNamesReusingOldState({
@@ -124742,10 +124722,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124742
124722
  getResolutionFromOldProgram,
124743
124723
  getResolved,
124744
124724
  canReuseResolutionsInFile,
124745
- isEntryResolvingToAmbientModule
124725
+ resolveToOwnAmbientModule
124746
124726
  }) {
124747
124727
  if (!entries.length) return emptyArray;
124748
- if (structureIsReused === 0 /* Not */ && (!isEntryResolvingToAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
124728
+ if (structureIsReused === 0 /* Not */ && (!resolveToOwnAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
124749
124729
  return resolutionWorker(
124750
124730
  entries,
124751
124731
  containingFile,
@@ -124781,12 +124761,23 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124781
124761
  continue;
124782
124762
  }
124783
124763
  }
124784
- if (isEntryResolvingToAmbientModule == null ? void 0 : isEntryResolvingToAmbientModule(entry, containingFile)) {
124785
- (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
124786
- } else {
124787
- (unknownEntries ?? (unknownEntries = [])).push(entry);
124788
- (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
124764
+ if (resolveToOwnAmbientModule) {
124765
+ const name = nameAndModeGetter.getName(entry);
124766
+ if (contains(containingSourceFile.ambientModuleNames, name)) {
124767
+ if (isTraceEnabled(options, host)) {
124768
+ trace(
124769
+ host,
124770
+ Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1,
124771
+ name,
124772
+ getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory)
124773
+ );
124774
+ }
124775
+ (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
124776
+ continue;
124777
+ }
124789
124778
  }
124779
+ (unknownEntries ?? (unknownEntries = [])).push(entry);
124780
+ (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
124790
124781
  }
124791
124782
  if (!unknownEntries) return result;
124792
124783
  const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
@@ -124920,10 +124911,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124920
124911
  } else if (hasInvalidatedResolutions(oldSourceFile.path)) {
124921
124912
  structureIsReused = 1 /* SafeModules */;
124922
124913
  modifiedSourceFiles.push(newSourceFile);
124923
- } else {
124924
- for (const moduleName of oldSourceFile.ambientModuleNames) {
124925
- ambientModuleNameToUnmodifiedFileName.set(moduleName, oldSourceFile.fileName);
124926
- }
124927
124914
  }
124928
124915
  newSourceFiles.push(newSourceFile);
124929
124916
  }
@@ -129512,7 +129499,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
129512
129499
  let filesWithChangedSetOfUnresolvedImports;
129513
129500
  let filesWithInvalidatedResolutions;
129514
129501
  let filesWithInvalidatedNonRelativeUnresolvedImports;
129515
- const nonRelativeExternalModuleResolutions = createMultiMap();
129502
+ const nonRelativeExternalModuleResolutions = /* @__PURE__ */ new Set();
129516
129503
  const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
129517
129504
  const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
129518
129505
  const resolvedFileToResolution = /* @__PURE__ */ new Map();
@@ -129663,8 +129650,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
129663
129650
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
129664
129651
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
129665
129652
  libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
129666
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
129667
- nonRelativeExternalModuleResolutions.clear();
129653
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
129668
129654
  isSymlinkCache.clear();
129669
129655
  }
129670
129656
  function cleanupLibResolutionWatching(newProgram) {
@@ -129683,8 +129669,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
129683
129669
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
129684
129670
  filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
129685
129671
  allModuleAndTypeResolutionsAreInvalidated = false;
129686
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
129687
- nonRelativeExternalModuleResolutions.clear();
129672
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
129688
129673
  if (newProgram !== oldProgram) {
129689
129674
  cleanupLibResolutionWatching(newProgram);
129690
129675
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
@@ -129947,7 +129932,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
129947
129932
  if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
129948
129933
  watchFailedLookupLocationOfResolution(resolution);
129949
129934
  } else {
129950
- nonRelativeExternalModuleResolutions.add(name, resolution);
129935
+ nonRelativeExternalModuleResolutions.add(resolution);
129951
129936
  }
129952
129937
  const resolved = getResolutionWithResolvedFileName(resolution);
129953
129938
  if (resolved && resolved.resolvedFileName) {
@@ -130083,17 +130068,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130083
130068
  (_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path2) => invalidateAffectingFileWatcher(path2, packageJsonMap));
130084
130069
  packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
130085
130070
  }
130086
- function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
130087
- const program = resolutionHost.getCurrentProgram();
130088
- if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
130089
- resolutions.forEach(watchFailedLookupLocationOfResolution);
130090
- } else {
130091
- resolutions.forEach((resolution) => watchAffectingLocationsOfResolution(
130092
- resolution,
130093
- /*addToResolutionsWithOnlyAffectingLocations*/
130094
- true
130095
- ));
130096
- }
130071
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
130072
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
130073
+ nonRelativeExternalModuleResolutions.clear();
130097
130074
  }
130098
130075
  function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
130099
130076
  Debug.assert(!nonRecursive);
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": "5.6.0-dev.20240712",
5
+ "version": "5.6.0-dev.20240714",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "20.1.0",
114
114
  "npm": "8.19.4"
115
115
  },
116
- "gitHead": "46410044add2e9f53cea58e445de18dcda53443f"
116
+ "gitHead": "6d3be985c82bead3b41348de76efec8110c677c5"
117
117
  }