@typescript-deploys/pr-build 4.8.0-pr-50085-2 → 4.8.0-pr-50098-2

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
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-insiders.20220728";
72
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220730";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -5727,6 +5727,10 @@ var ts;
5727
5727
  resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
5728
5728
  Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."),
5729
5729
  Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"),
5730
+ File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""),
5731
+ File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""),
5732
+ File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""),
5733
+ File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"),
5730
5734
  The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
5731
5735
  Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
5732
5736
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
@@ -19272,7 +19276,7 @@ var ts;
19272
19276
  propagateChildFlags(node.expression) |
19273
19277
  (ts.isIdentifier(node.name) ?
19274
19278
  propagateIdentifierNameFlags(node.name) :
19275
- propagateChildFlags(node.name));
19279
+ propagateChildFlags(node.name) | 536870912);
19276
19280
  if (ts.isSuperKeyword(expression)) {
19277
19281
  node.transformFlags |=
19278
19282
  256 |
@@ -19301,7 +19305,7 @@ var ts;
19301
19305
  propagateChildFlags(node.questionDotToken) |
19302
19306
  (ts.isIdentifier(node.name) ?
19303
19307
  propagateIdentifierNameFlags(node.name) :
19304
- propagateChildFlags(node.name));
19308
+ propagateChildFlags(node.name) | 536870912);
19305
19309
  return node;
19306
19310
  }
19307
19311
  function updatePropertyAccessChain(node, expression, questionDotToken, name) {
@@ -19660,6 +19664,9 @@ var ts;
19660
19664
  else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
19661
19665
  node.transformFlags |= 16;
19662
19666
  }
19667
+ if (operatorKind === 101 && ts.isPrivateIdentifier(node.left)) {
19668
+ node.transformFlags |= 536870912;
19669
+ }
19663
19670
  return node;
19664
19671
  }
19665
19672
  function propagateAssignmentPatternFlags(node) {
@@ -22086,29 +22093,29 @@ var ts;
22086
22093
  case 208:
22087
22094
  case 209:
22088
22095
  case 204:
22089
- return 536903680;
22096
+ return -2147450880;
22090
22097
  case 261:
22091
- return 742678528;
22098
+ return -1941676032;
22092
22099
  case 164:
22093
- return 536870912;
22100
+ return -2147483648;
22094
22101
  case 214:
22095
- return 612179968;
22102
+ return -2072174592;
22096
22103
  case 213:
22097
22104
  case 256:
22098
- return 746414080;
22105
+ return -1937940480;
22099
22106
  case 255:
22100
- return 537460736;
22107
+ return -2146893824;
22101
22108
  case 257:
22102
22109
  case 226:
22103
- return 537010176;
22110
+ return -2147344384;
22104
22111
  case 171:
22105
- return 746405888;
22112
+ return -1937948672;
22106
22113
  case 167:
22107
- return 671105024;
22114
+ return -2013249536;
22108
22115
  case 169:
22109
22116
  case 172:
22110
22117
  case 173:
22111
- return 679297024;
22118
+ return -2005057536;
22112
22119
  case 130:
22113
22120
  case 147:
22114
22121
  case 158:
@@ -22128,23 +22135,23 @@ var ts;
22128
22135
  case 259:
22129
22136
  return -2;
22130
22137
  case 205:
22131
- return 537075712;
22138
+ return -2147278848;
22132
22139
  case 292:
22133
- return 536936448;
22140
+ return -2147418112;
22134
22141
  case 201:
22135
22142
  case 202:
22136
- return 536903680;
22143
+ return -2147450880;
22137
22144
  case 211:
22138
22145
  case 229:
22139
22146
  case 350:
22140
22147
  case 212:
22141
22148
  case 106:
22142
- return 536870912;
22149
+ return -2147483648;
22143
22150
  case 206:
22144
22151
  case 207:
22145
- return 536870912;
22152
+ return -2147483648;
22146
22153
  default:
22147
- return 536870912;
22154
+ return -2147483648;
22148
22155
  }
22149
22156
  }
22150
22157
  ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
@@ -35331,7 +35338,7 @@ var ts;
35331
35338
  ts.createCacheWithRedirects = createCacheWithRedirects;
35332
35339
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
35333
35340
  var cache;
35334
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
35341
+ return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
35335
35342
  function getPackageJsonInfo(packageJsonPath) {
35336
35343
  return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
35337
35344
  }
@@ -35345,6 +35352,9 @@ var ts;
35345
35352
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
35346
35353
  return iter ? ts.arrayFrom(iter) : [];
35347
35354
  }
35355
+ function getInternalMap() {
35356
+ return cache;
35357
+ }
35348
35358
  }
35349
35359
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
35350
35360
  var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
@@ -35443,15 +35453,18 @@ var ts;
35443
35453
  }
35444
35454
  ts.zipToModeAwareCache = zipToModeAwareCache;
35445
35455
  function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35446
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35456
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35447
35457
  moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
35448
35458
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35449
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } });
35459
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35450
35460
  function clear() {
35451
- preDirectoryResolutionCache.clear();
35452
- moduleNameToDirectoryMap.clear();
35461
+ clearAllExceptPackageJsonInfoCache();
35453
35462
  packageJsonInfoCache.clear();
35454
35463
  }
35464
+ function clearAllExceptPackageJsonInfoCache() {
35465
+ perDirectoryResolutionCache.clear();
35466
+ moduleNameToDirectoryMap.clear();
35467
+ }
35455
35468
  function update(options) {
35456
35469
  updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
35457
35470
  }
@@ -35510,11 +35523,14 @@ var ts;
35510
35523
  function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
35511
35524
  var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35512
35525
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35513
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear });
35526
+ return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35514
35527
  function clear() {
35515
- preDirectoryResolutionCache.clear();
35528
+ clearAllExceptPackageJsonInfoCache();
35516
35529
  packageJsonInfoCache.clear();
35517
35530
  }
35531
+ function clearAllExceptPackageJsonInfoCache() {
35532
+ preDirectoryResolutionCache.clear();
35533
+ }
35518
35534
  }
35519
35535
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
35520
35536
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
@@ -43547,6 +43563,12 @@ var ts;
43547
43563
  return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
43548
43564
  }
43549
43565
  function typeToTypeNodeHelper(type, context) {
43566
+ var savedFlags = context.flags;
43567
+ var typeNode = typeToTypeNodeWorker(type, context);
43568
+ context.flags = savedFlags;
43569
+ return typeNode;
43570
+ }
43571
+ function typeToTypeNodeWorker(type, context) {
43550
43572
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
43551
43573
  cancellationToken.throwIfCancellationRequested();
43552
43574
  }
@@ -67769,7 +67791,7 @@ var ts;
67769
67791
  error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
67770
67792
  }
67771
67793
  }
67772
- if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
67794
+ if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) {
67773
67795
  error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
67774
67796
  }
67775
67797
  if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
@@ -81035,23 +81057,58 @@ var ts;
81035
81057
  function visitClassDeclaration(node) {
81036
81058
  if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
81037
81059
  return ts.visitEachChild(node, visitor, context);
81038
- var classStatement = ts.hasDecorators(node) ?
81039
- createClassDeclarationHeadWithDecorators(node, node.name) :
81040
- createClassDeclarationHeadWithoutDecorators(node, node.name);
81041
- var statements = [classStatement];
81042
- addClassElementDecorationStatements(statements, node, false);
81043
- addClassElementDecorationStatements(statements, node, true);
81044
- addConstructorDecorationStatement(statements, node);
81060
+ var statements = ts.hasDecorators(node) ?
81061
+ transformClassDeclarationWithClassDecorators(node, node.name) :
81062
+ transformClassDeclarationWithoutClassDecorators(node, node.name);
81045
81063
  if (statements.length > 1) {
81046
81064
  statements.push(factory.createEndOfDeclarationMarker(node));
81047
- ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
81065
+ ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304);
81048
81066
  }
81049
81067
  return ts.singleOrMany(statements);
81050
81068
  }
81051
- function createClassDeclarationHeadWithoutDecorators(node, name) {
81052
- return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
81069
+ function decoratorContainsPrivateIdentifierInExpression(decorator) {
81070
+ return !!(decorator.transformFlags & 536870912);
81071
+ }
81072
+ function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) {
81073
+ return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression);
81074
+ }
81075
+ function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) {
81076
+ for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
81077
+ var member = _a[_i];
81078
+ if (!ts.canHaveDecorators(member))
81079
+ continue;
81080
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
81081
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression))
81082
+ return true;
81083
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression))
81084
+ return true;
81085
+ }
81086
+ return false;
81053
81087
  }
81054
- function createClassDeclarationHeadWithDecorators(node, name) {
81088
+ function transformDecoratorsOfClassElements(node, members) {
81089
+ var decorationStatements = [];
81090
+ addClassElementDecorationStatements(decorationStatements, node, false);
81091
+ addClassElementDecorationStatements(decorationStatements, node, true);
81092
+ if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) {
81093
+ members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [
81094
+ factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, true))
81095
+ ], false)), members);
81096
+ decorationStatements = undefined;
81097
+ }
81098
+ return { decorationStatements: decorationStatements, members: members };
81099
+ }
81100
+ function transformClassDeclarationWithoutClassDecorators(node, name) {
81101
+ var _a;
81102
+ var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
81103
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
81104
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
81105
+ var decorationStatements = [];
81106
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
81107
+ var updated = factory.updateClassDeclaration(node, modifiers, name, undefined, heritageClauses, members);
81108
+ return ts.addRange([updated], decorationStatements);
81109
+ }
81110
+ function transformClassDeclarationWithClassDecorators(node, name) {
81111
+ var _a;
81055
81112
  var location = ts.moveRangePastModifiers(node);
81056
81113
  var classAlias = getClassAliasIfNeeded(node);
81057
81114
  var declName = languageVersion <= 2 ?
@@ -81059,6 +81116,8 @@ var ts;
81059
81116
  factory.getLocalName(node, false, true);
81060
81117
  var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
81061
81118
  var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
81119
+ var decorationStatements = [];
81120
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
81062
81121
  var classExpression = factory.createClassExpression(undefined, name, undefined, heritageClauses, members);
81063
81122
  ts.setOriginalNode(classExpression, node);
81064
81123
  ts.setTextRange(classExpression, location);
@@ -81068,7 +81127,10 @@ var ts;
81068
81127
  ts.setOriginalNode(statement, node);
81069
81128
  ts.setTextRange(statement, location);
81070
81129
  ts.setCommentRange(statement, node);
81071
- return statement;
81130
+ var statements = [statement];
81131
+ ts.addRange(statements, decorationStatements);
81132
+ addConstructorDecorationStatement(statements, node);
81133
+ return statements;
81072
81134
  }
81073
81135
  function visitClassExpression(node) {
81074
81136
  return factory.updateClassExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
@@ -97274,6 +97336,11 @@ var ts;
97274
97336
  }
97275
97337
  ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
97276
97338
  function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
97339
+ var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
97340
+ return typeof result === "object" ? result.impliedNodeFormat : result;
97341
+ }
97342
+ ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
97343
+ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
97277
97344
  switch (ts.getEmitModuleResolutionKind(options)) {
97278
97345
  case ts.ModuleResolutionKind.Node16:
97279
97346
  case ts.ModuleResolutionKind.NodeNext:
@@ -97285,11 +97352,16 @@ var ts;
97285
97352
  return undefined;
97286
97353
  }
97287
97354
  function lookupFromPackageJson() {
97288
- var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
97289
- return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97355
+ var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
97356
+ var packageJsonLocations = [];
97357
+ state.failedLookupLocations = packageJsonLocations;
97358
+ state.affectingLocations = packageJsonLocations;
97359
+ var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
97360
+ var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97361
+ return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
97290
97362
  }
97291
97363
  }
97292
- ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
97364
+ ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
97293
97365
  ts.plainJSErrors = new ts.Set([
97294
97366
  ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
97295
97367
  ts.Diagnostics.A_module_cannot_have_multiple_default_exports.code,
@@ -97567,7 +97639,7 @@ var ts;
97567
97639
  for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
97568
97640
  var oldSourceFile = oldSourceFiles_1[_i];
97569
97641
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
97570
- if (shouldCreateNewSourceFile || !newFile ||
97642
+ if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
97571
97643
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
97572
97644
  host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
97573
97645
  }
@@ -97897,7 +97969,7 @@ var ts;
97897
97969
  });
97898
97970
  }
97899
97971
  function tryReuseStructureFromOldProgram() {
97900
- var _a;
97972
+ var _a, _b;
97901
97973
  if (!oldProgram) {
97902
97974
  return 0;
97903
97975
  }
@@ -97925,12 +97997,15 @@ var ts;
97925
97997
  var seenPackageNames = new ts.Map();
97926
97998
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
97927
97999
  var oldSourceFile = oldSourceFiles_2[_i];
98000
+ var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
97928
98001
  var newSourceFile = host.getSourceFileByPath
97929
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile)
97930
- : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile);
98002
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
98003
+ : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat);
97931
98004
  if (!newSourceFile) {
97932
98005
  return 0;
97933
98006
  }
98007
+ newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
98008
+ newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
97934
98009
  ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
97935
98010
  var fileChanged = void 0;
97936
98011
  if (oldSourceFile.redirectInfo) {
@@ -97963,27 +98038,32 @@ var ts;
97963
98038
  seenPackageNames.set(packageName, newKind);
97964
98039
  }
97965
98040
  if (fileChanged) {
97966
- if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
97967
- structureIsReused = 1;
97968
- }
97969
- if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
97970
- structureIsReused = 1;
97971
- }
97972
- if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
98041
+ if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
97973
98042
  structureIsReused = 1;
97974
98043
  }
97975
- collectExternalModuleReferences(newSourceFile);
97976
- if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
98044
+ else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
97977
98045
  structureIsReused = 1;
97978
98046
  }
97979
- if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
98047
+ else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
97980
98048
  structureIsReused = 1;
97981
98049
  }
97982
- if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) {
98050
+ else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
97983
98051
  structureIsReused = 1;
97984
98052
  }
97985
- if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
97986
- structureIsReused = 1;
98053
+ else {
98054
+ collectExternalModuleReferences(newSourceFile);
98055
+ if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
98056
+ structureIsReused = 1;
98057
+ }
98058
+ else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
98059
+ structureIsReused = 1;
98060
+ }
98061
+ else if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) {
98062
+ structureIsReused = 1;
98063
+ }
98064
+ else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
98065
+ structureIsReused = 1;
98066
+ }
97987
98067
  }
97988
98068
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
97989
98069
  }
@@ -97997,17 +98077,17 @@ var ts;
97997
98077
  return structureIsReused;
97998
98078
  }
97999
98079
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
98000
- for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
98001
- var oldFile = oldSourceFiles_3[_b];
98080
+ for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
98081
+ var oldFile = oldSourceFiles_3[_c];
98002
98082
  if (!ts.contains(modifiedFiles, oldFile)) {
98003
- for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
98004
- var moduleName = _d[_c];
98083
+ for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
98084
+ var moduleName = _e[_d];
98005
98085
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
98006
98086
  }
98007
98087
  }
98008
98088
  }
98009
- for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
98010
- var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
98089
+ for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
98090
+ var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
98011
98091
  var moduleNames = getModuleNames(newSourceFile);
98012
98092
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98013
98093
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
@@ -98032,13 +98112,13 @@ var ts;
98032
98112
  if (structureIsReused !== 2) {
98033
98113
  return structureIsReused;
98034
98114
  }
98035
- if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) {
98115
+ if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
98036
98116
  return 1;
98037
98117
  }
98038
98118
  missingFilePaths = oldProgram.getMissingFilePaths();
98039
98119
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98040
- for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
98041
- var newSourceFile = newSourceFiles_1[_g];
98120
+ for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
98121
+ var newSourceFile = newSourceFiles_1[_h];
98042
98122
  filesByName.set(newSourceFile.path, newSourceFile);
98043
98123
  }
98044
98124
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -98769,14 +98849,14 @@ var ts;
98769
98849
  return result;
98770
98850
  }
98771
98851
  function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
98772
- var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
98773
- return {
98774
- languageVersion: ts.getEmitScriptTarget(options),
98775
- impliedNodeFormat: impliedNodeFormat,
98776
- setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
98777
- };
98852
+ var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
98853
+ var languageVersion = ts.getEmitScriptTarget(options);
98854
+ var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
98855
+ return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) :
98856
+ { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
98778
98857
  }
98779
98858
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
98859
+ var _a, _b;
98780
98860
  var path = toPath(fileName);
98781
98861
  if (useSourceOfProjectReferenceRedirect) {
98782
98862
  var source = getSourceOfProjectReferenceRedirect(path);
@@ -98846,7 +98926,8 @@ var ts;
98846
98926
  redirectedPath = toPath(redirect);
98847
98927
  }
98848
98928
  }
98849
- var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
98929
+ var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
98930
+ var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat));
98850
98931
  if (packageId) {
98851
98932
  var packageIdKey = ts.packageIdToString(packageId);
98852
98933
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -98871,6 +98952,8 @@ var ts;
98871
98952
  file.path = path;
98872
98953
  file.resolvedPath = toPath(fileName);
98873
98954
  file.originalFileName = originalFileName;
98955
+ file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
98956
+ file.packageJsonScope = sourceFileOptions.packageJsonScope;
98874
98957
  addFileIncludeReason(file, reason);
98875
98958
  if (host.useCaseSensitiveFileNames()) {
98876
98959
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -99447,7 +99530,7 @@ var ts;
99447
99530
  fileIncludeReasons = undefined;
99448
99531
  var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
99449
99532
  var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
99450
- var redirectInfo = file && ts.explainIfFileIsRedirect(file);
99533
+ var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file);
99451
99534
  var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
99452
99535
  return location && isReferenceFileLocation(location) ?
99453
99536
  ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
@@ -101414,7 +101497,7 @@ var ts;
101414
101497
  path;
101415
101498
  }
101416
101499
  ts.removeIgnoredPath = removeIgnoredPath;
101417
- function canWatchDirectory(dirPath) {
101500
+ function canWatchDirectoryOrFile(dirPath) {
101418
101501
  var rootLength = ts.getRootLength(dirPath);
101419
101502
  if (dirPath.length === rootLength) {
101420
101503
  return false;
@@ -101446,7 +101529,7 @@ var ts;
101446
101529
  }
101447
101530
  return true;
101448
101531
  }
101449
- ts.canWatchDirectory = canWatchDirectory;
101532
+ ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
101450
101533
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
101451
101534
  var filesWithChangedSetOfUnresolvedImports;
101452
101535
  var filesWithInvalidatedResolutions;
@@ -101455,7 +101538,9 @@ var ts;
101455
101538
  var resolutionsWithFailedLookups = [];
101456
101539
  var resolutionsWithOnlyAffectingLocations = [];
101457
101540
  var resolvedFileToResolution = ts.createMultiMap();
101541
+ var impliedFormatPackageJsons = new ts.Map();
101458
101542
  var hasChangedAutomaticTypeDirectiveNames = false;
101543
+ var affectingPathChecksForFile;
101459
101544
  var affectingPathChecks;
101460
101545
  var failedLookupChecks;
101461
101546
  var startsWithPathChecks;
@@ -101481,7 +101566,7 @@ var ts;
101481
101566
  getModuleResolutionCache: function () { return moduleResolutionCache; },
101482
101567
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
101483
101568
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
101484
- startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
101569
+ startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
101485
101570
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
101486
101571
  resolveModuleNames: resolveModuleNames,
101487
101572
  getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
@@ -101519,13 +101604,17 @@ var ts;
101519
101604
  resolvedModuleNames.clear();
101520
101605
  resolvedTypeReferenceDirectives.clear();
101521
101606
  resolvedFileToResolution.clear();
101607
+ nonRelativeExternalModuleResolutions.clear();
101522
101608
  resolutionsWithFailedLookups.length = 0;
101523
101609
  resolutionsWithOnlyAffectingLocations.length = 0;
101524
101610
  failedLookupChecks = undefined;
101525
101611
  startsWithPathChecks = undefined;
101526
101612
  isInDirectoryChecks = undefined;
101527
101613
  affectingPathChecks = undefined;
101528
- clearPerDirectoryResolutions();
101614
+ affectingPathChecksForFile = undefined;
101615
+ moduleResolutionCache.clear();
101616
+ typeReferenceDirectiveResolutionCache.clear();
101617
+ impliedFormatPackageJsons.clear();
101529
101618
  hasChangedAutomaticTypeDirectiveNames = false;
101530
101619
  }
101531
101620
  function startRecordingFilesWithChangedResolutions() {
@@ -101554,15 +101643,39 @@ var ts;
101554
101643
  return function (path) { return (!!collected && collected.has(path)) ||
101555
101644
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
101556
101645
  }
101557
- function clearPerDirectoryResolutions() {
101558
- moduleResolutionCache.clear();
101559
- typeReferenceDirectiveResolutionCache.clear();
101560
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101561
- nonRelativeExternalModuleResolutions.clear();
101646
+ function startCachingPerDirectoryResolution() {
101647
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
101648
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
101562
101649
  }
101563
- function finishCachingPerDirectoryResolution() {
101650
+ function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
101564
101651
  filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
101565
- clearPerDirectoryResolutions();
101652
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101653
+ nonRelativeExternalModuleResolutions.clear();
101654
+ if (newProgram !== oldProgram) {
101655
+ newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
101656
+ var _a, _b, _c;
101657
+ var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
101658
+ var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
101659
+ for (var i = existing.length; i < expected; i++) {
101660
+ createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], false);
101661
+ }
101662
+ if (existing.length > expected) {
101663
+ for (var i = expected; i < existing.length; i++) {
101664
+ fileWatchesOfAffectingLocations.get(existing[i]).files--;
101665
+ }
101666
+ }
101667
+ if (expected)
101668
+ impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
101669
+ else
101670
+ impliedFormatPackageJsons.delete(newFile.path);
101671
+ });
101672
+ impliedFormatPackageJsons.forEach(function (existing, path) {
101673
+ if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
101674
+ existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
101675
+ impliedFormatPackageJsons.delete(path);
101676
+ }
101677
+ });
101678
+ }
101566
101679
  directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
101567
101680
  if (watcher.refCount === 0) {
101568
101681
  directoryWatchesOfFailedLookups.delete(path);
@@ -101570,7 +101683,7 @@ var ts;
101570
101683
  }
101571
101684
  });
101572
101685
  fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
101573
- if (watcher.refCount === 0) {
101686
+ if (watcher.files === 0 && watcher.resolutions === 0) {
101574
101687
  fileWatchesOfAffectingLocations.delete(path);
101575
101688
  watcher.watcher.close();
101576
101689
  watcher.watcher = ts.noopFileWatcher;
@@ -101779,7 +101892,7 @@ var ts;
101779
101892
  dirPath = ts.getDirectoryPath(dirPath);
101780
101893
  }
101781
101894
  if (ts.isNodeModulesDirectory(dirPath)) {
101782
- return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
101895
+ return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
101783
101896
  }
101784
101897
  var nonRecursive = true;
101785
101898
  var subDirectoryPath, subDirectory;
@@ -101796,7 +101909,7 @@ var ts;
101796
101909
  dir = ts.getDirectoryPath(dir);
101797
101910
  }
101798
101911
  }
101799
- return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
101912
+ return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
101800
101913
  }
101801
101914
  function isPathWithDefaultFailedLookupExtension(path) {
101802
101915
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
@@ -101863,46 +101976,58 @@ var ts;
101863
101976
  resolutionsWithOnlyAffectingLocations.push(resolution);
101864
101977
  for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
101865
101978
  var affectingLocation = affectingLocations_1[_i];
101866
- createFileWatcherOfAffectingLocation(affectingLocation);
101979
+ createFileWatcherOfAffectingLocation(affectingLocation, true);
101867
101980
  }
101868
101981
  }
101869
- function createFileWatcherOfAffectingLocation(affectingLocation) {
101870
- var path = resolutionHost.toPath(affectingLocation);
101871
- var fileWatcher = fileWatchesOfAffectingLocations.get(path);
101982
+ function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
101983
+ var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
101872
101984
  if (fileWatcher) {
101873
- fileWatcher.refCount++;
101985
+ if (forResolution)
101986
+ fileWatcher.resolutions++;
101987
+ else
101988
+ fileWatcher.files++;
101874
101989
  return;
101875
101990
  }
101876
101991
  var locationToWatch = affectingLocation;
101877
- var locationToWatchPath = path;
101878
101992
  if (resolutionHost.realpath) {
101879
101993
  locationToWatch = resolutionHost.realpath(affectingLocation);
101880
- locationToWatchPath = resolutionHost.toPath(locationToWatch);
101881
- if (path !== locationToWatchPath) {
101882
- var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
101994
+ if (affectingLocation !== locationToWatch) {
101995
+ var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch);
101883
101996
  if (fileWatcher_1) {
101884
- fileWatcher_1.refCount++;
101885
- fileWatcher_1.paths.add(path);
101886
- fileWatchesOfAffectingLocations.set(path, fileWatcher_1);
101997
+ if (forResolution)
101998
+ fileWatcher_1.resolutions++;
101999
+ else
102000
+ fileWatcher_1.files++;
102001
+ fileWatcher_1.paths.add(affectingLocation);
102002
+ fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1);
101887
102003
  return;
101888
102004
  }
101889
102005
  }
101890
102006
  }
101891
102007
  var paths = new ts.Set();
101892
- paths.add(locationToWatchPath);
102008
+ paths.add(locationToWatch);
101893
102009
  var watcher = {
101894
- watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
101895
- cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
101896
- paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); });
101897
- resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
101898
- }),
101899
- refCount: 1,
102010
+ watcher: canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
102011
+ resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
102012
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
102013
+ paths.forEach(function (path) {
102014
+ var _a;
102015
+ if (watcher.resolutions)
102016
+ (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
102017
+ if (watcher.files)
102018
+ (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
102019
+ (_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
102020
+ });
102021
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
102022
+ }) : ts.noopFileWatcher,
102023
+ resolutions: forResolution ? 1 : 0,
102024
+ files: forResolution ? 0 : 1,
101900
102025
  paths: paths,
101901
102026
  };
101902
- fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
101903
- if (path !== locationToWatchPath) {
101904
- fileWatchesOfAffectingLocations.set(path, watcher);
101905
- paths.add(path);
102027
+ fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
102028
+ if (affectingLocation !== locationToWatch) {
102029
+ fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
102030
+ paths.add(affectingLocation);
101906
102031
  }
101907
102032
  }
101908
102033
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
@@ -101970,8 +102095,8 @@ var ts;
101970
102095
  }
101971
102096
  for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
101972
102097
  var affectingLocation = affectingLocations_2[_a];
101973
- var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
101974
- watcher.refCount--;
102098
+ var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102099
+ watcher.resolutions--;
101975
102100
  }
101976
102101
  }
101977
102102
  function removeDirectoryWatcher(dirPath) {
@@ -102020,7 +102145,7 @@ var ts;
102020
102145
  resolution.isInvalidated = invalidated = true;
102021
102146
  for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
102022
102147
  var containingFilePath = _b[_a];
102023
- (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
102148
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
102024
102149
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
102025
102150
  }
102026
102151
  }
@@ -102073,10 +102198,25 @@ var ts;
102073
102198
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
102074
102199
  }
102075
102200
  function invalidateResolutionsOfFailedLookupLocations() {
102201
+ var _a;
102202
+ var invalidated = false;
102203
+ if (affectingPathChecksForFile) {
102204
+ (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
102205
+ if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
102206
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
102207
+ invalidated = true;
102208
+ }
102209
+ });
102210
+ affectingPathChecksForFile = undefined;
102211
+ }
102076
102212
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
102077
- return false;
102213
+ return invalidated;
102214
+ }
102215
+ invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
102216
+ var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
102217
+ if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
102218
+ packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; });
102078
102219
  }
102079
- var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
102080
102220
  failedLookupChecks = undefined;
102081
102221
  startsWithPathChecks = undefined;
102082
102222
  isInDirectoryChecks = undefined;
@@ -102089,17 +102229,15 @@ var ts;
102089
102229
  return true;
102090
102230
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
102091
102231
  return false;
102092
- return resolution.failedLookupLocations.some(function (location) {
102093
- var locationPath = resolutionHost.toPath(location);
102094
- return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
102095
- ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
102096
- ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
102097
- });
102232
+ return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); });
102233
+ }
102234
+ function isInvalidatedFailedLookup(locationPath) {
102235
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
102236
+ ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
102237
+ ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
102098
102238
  }
102099
102239
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
102100
- return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
102101
- return affectingPathChecks.has(resolutionHost.toPath(location));
102102
- });
102240
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
102103
102241
  }
102104
102242
  function closeTypeRootsWatch() {
102105
102243
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -102145,7 +102283,7 @@ var ts;
102145
102283
  function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
102146
102284
  var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
102147
102285
  var dirPath = resolutionHost.toPath(dir);
102148
- return dirPath === rootPath || canWatchDirectory(dirPath);
102286
+ return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
102149
102287
  }
102150
102288
  }
102151
102289
  ts.createResolutionCache = createResolutionCache;
@@ -102990,21 +103128,41 @@ var ts;
102990
103128
  var file = _c[_i];
102991
103129
  write("" + toFileName(file, relativeFileName));
102992
103130
  (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
102993
- (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
103131
+ (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
102994
103132
  }
102995
103133
  }
102996
103134
  ts.explainFiles = explainFiles;
102997
- function explainIfFileIsRedirect(file, fileNameConvertor) {
103135
+ function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
103136
+ var _a;
102998
103137
  var result;
102999
103138
  if (file.path !== file.resolvedPath) {
103000
- (result || (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
103139
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
103001
103140
  }
103002
103141
  if (file.redirectInfo) {
103003
- (result || (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
103142
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
103143
+ }
103144
+ if (ts.isExternalOrCommonJsModule(file)) {
103145
+ switch (file.impliedNodeFormat) {
103146
+ case ts.ModuleKind.ESNext:
103147
+ if (file.packageJsonScope) {
103148
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
103149
+ }
103150
+ break;
103151
+ case ts.ModuleKind.CommonJS:
103152
+ if (file.packageJsonScope) {
103153
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.packageJsonContent.type ?
103154
+ ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
103155
+ ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
103156
+ }
103157
+ else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
103158
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
103159
+ }
103160
+ break;
103161
+ }
103004
103162
  }
103005
103163
  return result;
103006
103164
  }
103007
- ts.explainIfFileIsRedirect = explainIfFileIsRedirect;
103165
+ ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat;
103008
103166
  function getMatchedFileSpec(program, fileName) {
103009
103167
  var _a;
103010
103168
  var configFile = program.getCompilerOptions().configFile;
@@ -103197,6 +103355,7 @@ var ts;
103197
103355
  MissingFile: "Missing file",
103198
103356
  WildcardDirectory: "Wild card directory",
103199
103357
  FailedLookupLocations: "Failed Lookup Locations",
103358
+ AffectingFileLocation: "File location affecting resolution",
103200
103359
  TypeRoots: "Type roots",
103201
103360
  ConfigFileOfReferencedProject: "Config file of referened project",
103202
103361
  ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
@@ -103498,7 +103657,7 @@ var ts;
103498
103657
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
103499
103658
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
103500
103659
  compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
103501
- compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); };
103660
+ compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); };
103502
103661
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
103503
103662
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
103504
103663
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -103529,6 +103688,9 @@ var ts;
103529
103688
  return host.resolveTypeReferenceDirectives.apply(host, args);
103530
103689
  }) :
103531
103690
  (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
103691
+ compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
103692
+ ts.maybeBind(host, host.getModuleResolutionCache) :
103693
+ (function () { return resolutionCache.getModuleResolutionCache(); });
103532
103694
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
103533
103695
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
103534
103696
  synchronizeProgram();
@@ -103627,8 +103789,9 @@ var ts;
103627
103789
  resolutionCache.startCachingPerDirectoryResolution();
103628
103790
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
103629
103791
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
103792
+ var oldProgram = getCurrentProgram();
103630
103793
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
103631
- resolutionCache.finishCachingPerDirectoryResolution();
103794
+ resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
103632
103795
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
103633
103796
  if (needsUpdateInTypeRootWatch) {
103634
103797
  resolutionCache.updateTypeRootsWatch();
@@ -103698,9 +103861,6 @@ var ts;
103698
103861
  sourceFilesCache.set(path, false);
103699
103862
  }
103700
103863
  }
103701
- if (sourceFile) {
103702
- sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
103703
- }
103704
103864
  return sourceFile;
103705
103865
  }
103706
103866
  return hostSourceFile.sourceFile;
@@ -104153,6 +104313,7 @@ var ts;
104153
104313
  compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
104154
104314
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
104155
104315
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
104316
+ compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
104156
104317
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
104157
104318
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
104158
104319
  if (!compilerHost.resolveModuleNames) {