@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.
@@ -303,7 +303,7 @@ var ts;
303
303
  // The following is baselined as a literal template type without intervention
304
304
  /** The version of the TypeScript compiler release */
305
305
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
306
- ts.version = ts.versionMajorMinor + ".0-insiders.20220728";
306
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220730";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -5916,10 +5916,8 @@ var ts;
5916
5916
  TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5917
5917
  TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5918
5918
  TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5919
- // Please leave this as 1 << 29.
5920
- // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5921
- // It is a good reminder of how much room we have left
5922
- TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
5919
+ TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression";
5920
+ TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags";
5923
5921
  // Assertions
5924
5922
  // - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
5925
5923
  TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript";
@@ -5938,23 +5936,23 @@ var ts;
5938
5936
  // Scope Exclusions
5939
5937
  // - Bitmasks that exclude flags from propagating out of a specific context
5940
5938
  // into the subtree flags of their container.
5941
- TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5942
- TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5943
- TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5944
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5945
- TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5946
- TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5947
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5948
- TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5949
- TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5950
- TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5939
+ TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes";
5940
+ TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes";
5941
+ TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes";
5942
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes";
5943
+ TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes";
5944
+ TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes";
5945
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes";
5946
+ TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes";
5947
+ TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes";
5948
+ TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes";
5951
5949
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5952
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5953
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5954
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5955
- TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5956
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5957
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5950
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes";
5951
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes";
5952
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes";
5953
+ TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes";
5954
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes";
5955
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes";
5958
5956
  TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5959
5957
  // Propagating flags
5960
5958
  // - Bitmasks for flags that should propagate from a child
@@ -8767,6 +8765,10 @@ var ts;
8767
8765
  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."),
8768
8766
  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`."),
8769
8767
  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 '**/*'"),
8768
+ 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\""),
8769
+ 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\""),
8770
+ 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\""),
8771
+ 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"),
8770
8772
  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."),
8771
8773
  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."),
8772
8774
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
@@ -24293,7 +24295,7 @@ var ts;
24293
24295
  propagateChildFlags(node.expression) |
24294
24296
  (ts.isIdentifier(node.name) ?
24295
24297
  propagateIdentifierNameFlags(node.name) :
24296
- propagateChildFlags(node.name));
24298
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24297
24299
  if (ts.isSuperKeyword(expression)) {
24298
24300
  // super method calls require a lexical 'this'
24299
24301
  // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
@@ -24326,7 +24328,7 @@ var ts;
24326
24328
  propagateChildFlags(node.questionDotToken) |
24327
24329
  (ts.isIdentifier(node.name) ?
24328
24330
  propagateIdentifierNameFlags(node.name) :
24329
- propagateChildFlags(node.name));
24331
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24330
24332
  return node;
24331
24333
  }
24332
24334
  // @api
@@ -24730,6 +24732,9 @@ var ts;
24730
24732
  else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
24731
24733
  node.transformFlags |= 16 /* ContainsES2021 */;
24732
24734
  }
24735
+ if (operatorKind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
24736
+ node.transformFlags |= 536870912 /* ContainsPrivateIdentifierInExpression */;
24737
+ }
24733
24738
  return node;
24734
24739
  }
24735
24740
  function propagateAssignmentPatternFlags(node) {
@@ -27684,29 +27689,29 @@ var ts;
27684
27689
  case 208 /* CallExpression */:
27685
27690
  case 209 /* NewExpression */:
27686
27691
  case 204 /* ArrayLiteralExpression */:
27687
- return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27692
+ return -2147450880 /* ArrayLiteralOrCallOrNewExcludes */;
27688
27693
  case 261 /* ModuleDeclaration */:
27689
- return 742678528 /* ModuleExcludes */;
27694
+ return -1941676032 /* ModuleExcludes */;
27690
27695
  case 164 /* Parameter */:
27691
- return 536870912 /* ParameterExcludes */;
27696
+ return -2147483648 /* ParameterExcludes */;
27692
27697
  case 214 /* ArrowFunction */:
27693
- return 612179968 /* ArrowFunctionExcludes */;
27698
+ return -2072174592 /* ArrowFunctionExcludes */;
27694
27699
  case 213 /* FunctionExpression */:
27695
27700
  case 256 /* FunctionDeclaration */:
27696
- return 746414080 /* FunctionExcludes */;
27701
+ return -1937940480 /* FunctionExcludes */;
27697
27702
  case 255 /* VariableDeclarationList */:
27698
- return 537460736 /* VariableDeclarationListExcludes */;
27703
+ return -2146893824 /* VariableDeclarationListExcludes */;
27699
27704
  case 257 /* ClassDeclaration */:
27700
27705
  case 226 /* ClassExpression */:
27701
- return 537010176 /* ClassExcludes */;
27706
+ return -2147344384 /* ClassExcludes */;
27702
27707
  case 171 /* Constructor */:
27703
- return 746405888 /* ConstructorExcludes */;
27708
+ return -1937948672 /* ConstructorExcludes */;
27704
27709
  case 167 /* PropertyDeclaration */:
27705
- return 671105024 /* PropertyExcludes */;
27710
+ return -2013249536 /* PropertyExcludes */;
27706
27711
  case 169 /* MethodDeclaration */:
27707
27712
  case 172 /* GetAccessor */:
27708
27713
  case 173 /* SetAccessor */:
27709
- return 679297024 /* MethodOrAccessorExcludes */;
27714
+ return -2005057536 /* MethodOrAccessorExcludes */;
27710
27715
  case 130 /* AnyKeyword */:
27711
27716
  case 147 /* NumberKeyword */:
27712
27717
  case 158 /* BigIntKeyword */:
@@ -27726,23 +27731,23 @@ var ts;
27726
27731
  case 259 /* TypeAliasDeclaration */:
27727
27732
  return -2 /* TypeExcludes */;
27728
27733
  case 205 /* ObjectLiteralExpression */:
27729
- return 537075712 /* ObjectLiteralExcludes */;
27734
+ return -2147278848 /* ObjectLiteralExcludes */;
27730
27735
  case 292 /* CatchClause */:
27731
- return 536936448 /* CatchClauseExcludes */;
27736
+ return -2147418112 /* CatchClauseExcludes */;
27732
27737
  case 201 /* ObjectBindingPattern */:
27733
27738
  case 202 /* ArrayBindingPattern */:
27734
- return 536903680 /* BindingPatternExcludes */;
27739
+ return -2147450880 /* BindingPatternExcludes */;
27735
27740
  case 211 /* TypeAssertionExpression */:
27736
27741
  case 229 /* AsExpression */:
27737
27742
  case 350 /* PartiallyEmittedExpression */:
27738
27743
  case 212 /* ParenthesizedExpression */:
27739
27744
  case 106 /* SuperKeyword */:
27740
- return 536870912 /* OuterExpressionExcludes */;
27745
+ return -2147483648 /* OuterExpressionExcludes */;
27741
27746
  case 206 /* PropertyAccessExpression */:
27742
27747
  case 207 /* ElementAccessExpression */:
27743
- return 536870912 /* PropertyAccessExcludes */;
27748
+ return -2147483648 /* PropertyAccessExcludes */;
27744
27749
  default:
27745
- return 536870912 /* NodeExcludes */;
27750
+ return -2147483648 /* NodeExcludes */;
27746
27751
  }
27747
27752
  }
27748
27753
  ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
@@ -43441,7 +43446,7 @@ var ts;
43441
43446
  ts.createCacheWithRedirects = createCacheWithRedirects;
43442
43447
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
43443
43448
  var cache;
43444
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
43449
+ return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
43445
43450
  function getPackageJsonInfo(packageJsonPath) {
43446
43451
  return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
43447
43452
  }
@@ -43455,6 +43460,9 @@ var ts;
43455
43460
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
43456
43461
  return iter ? ts.arrayFrom(iter) : [];
43457
43462
  }
43463
+ function getInternalMap() {
43464
+ return cache;
43465
+ }
43458
43466
  }
43459
43467
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
43460
43468
  var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
@@ -43558,15 +43566,18 @@ var ts;
43558
43566
  }
43559
43567
  ts.zipToModeAwareCache = zipToModeAwareCache;
43560
43568
  function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
43561
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43569
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43562
43570
  moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
43563
43571
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
43564
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } });
43572
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43565
43573
  function clear() {
43566
- preDirectoryResolutionCache.clear();
43567
- moduleNameToDirectoryMap.clear();
43574
+ clearAllExceptPackageJsonInfoCache();
43568
43575
  packageJsonInfoCache.clear();
43569
43576
  }
43577
+ function clearAllExceptPackageJsonInfoCache() {
43578
+ perDirectoryResolutionCache.clear();
43579
+ moduleNameToDirectoryMap.clear();
43580
+ }
43570
43581
  function update(options) {
43571
43582
  updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
43572
43583
  }
@@ -43644,11 +43655,14 @@ var ts;
43644
43655
  function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
43645
43656
  var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43646
43657
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
43647
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear });
43658
+ return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43648
43659
  function clear() {
43649
- preDirectoryResolutionCache.clear();
43660
+ clearAllExceptPackageJsonInfoCache();
43650
43661
  packageJsonInfoCache.clear();
43651
43662
  }
43663
+ function clearAllExceptPackageJsonInfoCache() {
43664
+ preDirectoryResolutionCache.clear();
43665
+ }
43652
43666
  }
43653
43667
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
43654
43668
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
@@ -53089,6 +53103,12 @@ var ts;
53089
53103
  return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
53090
53104
  }
53091
53105
  function typeToTypeNodeHelper(type, context) {
53106
+ var savedFlags = context.flags;
53107
+ var typeNode = typeToTypeNodeWorker(type, context);
53108
+ context.flags = savedFlags;
53109
+ return typeNode;
53110
+ }
53111
+ function typeToTypeNodeWorker(type, context) {
53092
53112
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
53093
53113
  cancellationToken.throwIfCancellationRequested();
53094
53114
  }
@@ -80982,7 +81002,7 @@ var ts;
80982
81002
  error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
80983
81003
  }
80984
81004
  }
80985
- if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
81005
+ if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) {
80986
81006
  error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
80987
81007
  }
80988
81008
  if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
@@ -96787,39 +96807,72 @@ var ts;
96787
96807
  function visitClassDeclaration(node) {
96788
96808
  if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
96789
96809
  return ts.visitEachChild(node, visitor, context);
96790
- var classStatement = ts.hasDecorators(node) ?
96791
- createClassDeclarationHeadWithDecorators(node, node.name) :
96792
- createClassDeclarationHeadWithoutDecorators(node, node.name);
96793
- var statements = [classStatement];
96794
- // Write any decorators of the node.
96795
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
96796
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
96797
- addConstructorDecorationStatement(statements, node);
96810
+ var statements = ts.hasDecorators(node) ?
96811
+ transformClassDeclarationWithClassDecorators(node, node.name) :
96812
+ transformClassDeclarationWithoutClassDecorators(node, node.name);
96798
96813
  if (statements.length > 1) {
96799
96814
  // Add a DeclarationMarker as a marker for the end of the declaration
96800
96815
  statements.push(factory.createEndOfDeclarationMarker(node));
96801
- ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
96816
+ ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* HasEndOfDeclarationMarker */);
96802
96817
  }
96803
96818
  return ts.singleOrMany(statements);
96804
96819
  }
96820
+ function decoratorContainsPrivateIdentifierInExpression(decorator) {
96821
+ return !!(decorator.transformFlags & 536870912 /* ContainsPrivateIdentifierInExpression */);
96822
+ }
96823
+ function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) {
96824
+ return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression);
96825
+ }
96826
+ function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) {
96827
+ for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
96828
+ var member = _a[_i];
96829
+ if (!ts.canHaveDecorators(member))
96830
+ continue;
96831
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96832
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression))
96833
+ return true;
96834
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression))
96835
+ return true;
96836
+ }
96837
+ return false;
96838
+ }
96839
+ function transformDecoratorsOfClassElements(node, members) {
96840
+ var decorationStatements = [];
96841
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false);
96842
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true);
96843
+ if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) {
96844
+ members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [
96845
+ factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true))
96846
+ ], false)), members);
96847
+ decorationStatements = undefined;
96848
+ }
96849
+ return { decorationStatements: decorationStatements, members: members };
96850
+ }
96805
96851
  /**
96806
96852
  * Transforms a non-decorated class declaration.
96807
96853
  *
96808
96854
  * @param node A ClassDeclaration node.
96809
96855
  * @param name The name of the class.
96810
96856
  */
96811
- function createClassDeclarationHeadWithoutDecorators(node, name) {
96857
+ function transformClassDeclarationWithoutClassDecorators(node, name) {
96812
96858
  // ${modifiers} class ${name} ${heritageClauses} {
96813
96859
  // ${members}
96814
96860
  // }
96815
- return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name,
96816
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96861
+ var _a;
96862
+ var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
96863
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96864
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96865
+ var decorationStatements = [];
96866
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96867
+ var updated = factory.updateClassDeclaration(node, modifiers, name,
96868
+ /*typeParameters*/ undefined, heritageClauses, members);
96869
+ return ts.addRange([updated], decorationStatements);
96817
96870
  }
96818
96871
  /**
96819
96872
  * Transforms a decorated class declaration and appends the resulting statements. If
96820
96873
  * the class requires an alias to avoid issues with double-binding, the alias is returned.
96821
96874
  */
96822
- function createClassDeclarationHeadWithDecorators(node, name) {
96875
+ function transformClassDeclarationWithClassDecorators(node, name) {
96823
96876
  // When we emit an ES6 class that has a class decorator, we must tailor the
96824
96877
  // emit to certain specific cases.
96825
96878
  //
@@ -96905,6 +96958,7 @@ var ts;
96905
96958
  // | var C_1;
96906
96959
  // ---------------------------------------------------------------------
96907
96960
  //
96961
+ var _a;
96908
96962
  var location = ts.moveRangePastModifiers(node);
96909
96963
  var classAlias = getClassAliasIfNeeded(node);
96910
96964
  // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
@@ -96917,7 +96971,11 @@ var ts;
96917
96971
  // }
96918
96972
  var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96919
96973
  var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96920
- var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
96974
+ var decorationStatements = [];
96975
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96976
+ var classExpression = factory.createClassExpression(
96977
+ /*modifiers*/ undefined, name,
96978
+ /*typeParameters*/ undefined, heritageClauses, members);
96921
96979
  ts.setOriginalNode(classExpression, node);
96922
96980
  ts.setTextRange(classExpression, location);
96923
96981
  // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
@@ -96931,7 +96989,10 @@ var ts;
96931
96989
  ts.setOriginalNode(statement, node);
96932
96990
  ts.setTextRange(statement, location);
96933
96991
  ts.setCommentRange(statement, node);
96934
- return statement;
96992
+ var statements = [statement];
96993
+ ts.addRange(statements, decorationStatements);
96994
+ addConstructorDecorationStatement(statements, node);
96995
+ return statements;
96935
96996
  }
96936
96997
  function visitClassExpression(node) {
96937
96998
  // Legacy decorators were not supported on class expressions
@@ -117848,6 +117909,12 @@ var ts;
117848
117909
  * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
117849
117910
  */
117850
117911
  function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
117912
+ var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
117913
+ return typeof result === "object" ? result.impliedNodeFormat : result;
117914
+ }
117915
+ ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
117916
+ /*@internal*/
117917
+ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
117851
117918
  switch (ts.getEmitModuleResolutionKind(options)) {
117852
117919
  case ts.ModuleResolutionKind.Node16:
117853
117920
  case ts.ModuleResolutionKind.NodeNext:
@@ -117859,11 +117926,16 @@ var ts;
117859
117926
  return undefined;
117860
117927
  }
117861
117928
  function lookupFromPackageJson() {
117862
- var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
117863
- return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117929
+ var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
117930
+ var packageJsonLocations = [];
117931
+ state.failedLookupLocations = packageJsonLocations;
117932
+ state.affectingLocations = packageJsonLocations;
117933
+ var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
117934
+ var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117935
+ return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
117864
117936
  }
117865
117937
  }
117866
- ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
117938
+ ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
117867
117939
  /** @internal */
117868
117940
  ts.plainJSErrors = new ts.Set([
117869
117941
  // binder errors
@@ -118188,7 +118260,7 @@ var ts;
118188
118260
  for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
118189
118261
  var oldSourceFile = oldSourceFiles_1[_i];
118190
118262
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
118191
- if (shouldCreateNewSourceFile || !newFile ||
118263
+ if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
118192
118264
  // old file wasn't redirect but new file is
118193
118265
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
118194
118266
  host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
@@ -118581,7 +118653,7 @@ var ts;
118581
118653
  });
118582
118654
  }
118583
118655
  function tryReuseStructureFromOldProgram() {
118584
- var _a;
118656
+ var _a, _b;
118585
118657
  if (!oldProgram) {
118586
118658
  return 0 /* Not */;
118587
118659
  }
@@ -118622,12 +118694,15 @@ var ts;
118622
118694
  var seenPackageNames = new ts.Map();
118623
118695
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
118624
118696
  var oldSourceFile = oldSourceFiles_2[_i];
118697
+ var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
118625
118698
  var newSourceFile = host.getSourceFileByPath
118626
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
118627
- : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
118699
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
118700
+ : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
118628
118701
  if (!newSourceFile) {
118629
118702
  return 0 /* Not */;
118630
118703
  }
118704
+ newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
118705
+ newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
118631
118706
  ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
118632
118707
  var fileChanged = void 0;
118633
118708
  if (oldSourceFile.redirectInfo) {
@@ -118667,38 +118742,43 @@ var ts;
118667
118742
  seenPackageNames.set(packageName, newKind);
118668
118743
  }
118669
118744
  if (fileChanged) {
118745
+ if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
118746
+ structureIsReused = 1 /* SafeModules */;
118747
+ }
118670
118748
  // The `newSourceFile` object was created for the new program.
118671
- if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
118749
+ else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
118672
118750
  // 'lib' references has changed. Matches behavior in changesAffectModuleResolution
118673
118751
  structureIsReused = 1 /* SafeModules */;
118674
118752
  }
118675
- if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
118753
+ else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
118676
118754
  // value of no-default-lib has changed
118677
118755
  // this will affect if default library is injected into the list of files
118678
118756
  structureIsReused = 1 /* SafeModules */;
118679
118757
  }
118680
118758
  // check tripleslash references
118681
- if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
118759
+ else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
118682
118760
  // tripleslash references has changed
118683
118761
  structureIsReused = 1 /* SafeModules */;
118684
118762
  }
118685
- // check imports and module augmentations
118686
- collectExternalModuleReferences(newSourceFile);
118687
- if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
118688
- // imports has changed
118689
- structureIsReused = 1 /* SafeModules */;
118690
- }
118691
- if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
118692
- // moduleAugmentations has changed
118693
- structureIsReused = 1 /* SafeModules */;
118694
- }
118695
- if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
118696
- // dynamicImport has changed
118697
- structureIsReused = 1 /* SafeModules */;
118698
- }
118699
- if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
118700
- // 'types' references has changed
118701
- structureIsReused = 1 /* SafeModules */;
118763
+ else {
118764
+ // check imports and module augmentations
118765
+ collectExternalModuleReferences(newSourceFile);
118766
+ if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
118767
+ // imports has changed
118768
+ structureIsReused = 1 /* SafeModules */;
118769
+ }
118770
+ else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
118771
+ // moduleAugmentations has changed
118772
+ structureIsReused = 1 /* SafeModules */;
118773
+ }
118774
+ else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
118775
+ // dynamicImport has changed
118776
+ structureIsReused = 1 /* SafeModules */;
118777
+ }
118778
+ else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
118779
+ // 'types' references has changed
118780
+ structureIsReused = 1 /* SafeModules */;
118781
+ }
118702
118782
  }
118703
118783
  // tentatively approve the file
118704
118784
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
@@ -118716,18 +118796,18 @@ var ts;
118716
118796
  return structureIsReused;
118717
118797
  }
118718
118798
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
118719
- for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
118720
- var oldFile = oldSourceFiles_3[_b];
118799
+ for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
118800
+ var oldFile = oldSourceFiles_3[_c];
118721
118801
  if (!ts.contains(modifiedFiles, oldFile)) {
118722
- for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
118723
- var moduleName = _d[_c];
118802
+ for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
118803
+ var moduleName = _e[_d];
118724
118804
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
118725
118805
  }
118726
118806
  }
118727
118807
  }
118728
118808
  // try to verify results of module resolution
118729
- for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
118730
- var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
118809
+ for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
118810
+ var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
118731
118811
  var moduleNames = getModuleNames(newSourceFile);
118732
118812
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
118733
118813
  // ensure that module resolution results are still correct
@@ -118754,14 +118834,14 @@ var ts;
118754
118834
  if (structureIsReused !== 2 /* Completely */) {
118755
118835
  return structureIsReused;
118756
118836
  }
118757
- if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) {
118837
+ if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
118758
118838
  return 1 /* SafeModules */;
118759
118839
  }
118760
118840
  missingFilePaths = oldProgram.getMissingFilePaths();
118761
118841
  // update fileName -> file mapping
118762
118842
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
118763
- for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
118764
- var newSourceFile = newSourceFiles_1[_g];
118843
+ for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
118844
+ var newSourceFile = newSourceFiles_1[_h];
118765
118845
  filesByName.set(newSourceFile.path, newSourceFile);
118766
118846
  }
118767
118847
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -119551,6 +119631,7 @@ var ts;
119551
119631
  redirect.resolvedPath = resolvedPath;
119552
119632
  redirect.originalFileName = originalFileName;
119553
119633
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
119634
+ // TODO:" shkamat"
119554
119635
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
119555
119636
  Object.defineProperties(redirect, {
119556
119637
  id: {
@@ -119579,14 +119660,14 @@ var ts;
119579
119660
  // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
119580
119661
  // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
119581
119662
  // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
119582
- var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
119583
- return {
119584
- languageVersion: ts.getEmitScriptTarget(options),
119585
- impliedNodeFormat: impliedNodeFormat,
119586
- setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
119587
- };
119663
+ var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
119664
+ var languageVersion = ts.getEmitScriptTarget(options);
119665
+ var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
119666
+ return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) :
119667
+ { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
119588
119668
  }
119589
119669
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
119670
+ var _a, _b;
119590
119671
  var path = toPath(fileName);
119591
119672
  if (useSourceOfProjectReferenceRedirect) {
119592
119673
  var source = getSourceOfProjectReferenceRedirect(path);
@@ -119673,7 +119754,8 @@ var ts;
119673
119754
  }
119674
119755
  }
119675
119756
  // We haven't looked for this file, do so now and cache result
119676
- var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
119757
+ var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
119758
+ var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ 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));
119677
119759
  if (packageId) {
119678
119760
  var packageIdKey = ts.packageIdToString(packageId);
119679
119761
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -119701,6 +119783,9 @@ var ts;
119701
119783
  file.path = path;
119702
119784
  file.resolvedPath = toPath(fileName);
119703
119785
  file.originalFileName = originalFileName;
119786
+ file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
119787
+ file.packageJsonScope = sourceFileOptions.packageJsonScope;
119788
+ // TODO: handle watch when same file has changes in failed and affecting locations
119704
119789
  addFileIncludeReason(file, reason);
119705
119790
  if (host.useCaseSensitiveFileNames()) {
119706
119791
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -120331,7 +120416,7 @@ var ts;
120331
120416
  fileIncludeReasons = undefined;
120332
120417
  var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
120333
120418
  var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
120334
- var redirectInfo = file && ts.explainIfFileIsRedirect(file);
120419
+ var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file);
120335
120420
  var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
120336
120421
  return location && isReferenceFileLocation(location) ?
120337
120422
  ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
@@ -122636,7 +122721,7 @@ var ts;
122636
122721
  * "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot"
122637
122722
  * @param dirPath
122638
122723
  */
122639
- function canWatchDirectory(dirPath) {
122724
+ function canWatchDirectoryOrFile(dirPath) {
122640
122725
  var rootLength = ts.getRootLength(dirPath);
122641
122726
  if (dirPath.length === rootLength) {
122642
122727
  // Ignore "/", "c:/"
@@ -122673,7 +122758,7 @@ var ts;
122673
122758
  }
122674
122759
  return true;
122675
122760
  }
122676
- ts.canWatchDirectory = canWatchDirectory;
122761
+ ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
122677
122762
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
122678
122763
  var filesWithChangedSetOfUnresolvedImports;
122679
122764
  var filesWithInvalidatedResolutions;
@@ -122682,7 +122767,9 @@ var ts;
122682
122767
  var resolutionsWithFailedLookups = [];
122683
122768
  var resolutionsWithOnlyAffectingLocations = [];
122684
122769
  var resolvedFileToResolution = ts.createMultiMap();
122770
+ var impliedFormatPackageJsons = new ts.Map();
122685
122771
  var hasChangedAutomaticTypeDirectiveNames = false;
122772
+ var affectingPathChecksForFile;
122686
122773
  var affectingPathChecks;
122687
122774
  var failedLookupChecks;
122688
122775
  var startsWithPathChecks;
@@ -122722,7 +122809,7 @@ var ts;
122722
122809
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
122723
122810
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122724
122811
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122725
- startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
122812
+ startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
122726
122813
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
122727
122814
  resolveModuleNames: resolveModuleNames,
122728
122815
  getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
@@ -122760,15 +122847,19 @@ var ts;
122760
122847
  resolvedModuleNames.clear();
122761
122848
  resolvedTypeReferenceDirectives.clear();
122762
122849
  resolvedFileToResolution.clear();
122850
+ nonRelativeExternalModuleResolutions.clear();
122763
122851
  resolutionsWithFailedLookups.length = 0;
122764
122852
  resolutionsWithOnlyAffectingLocations.length = 0;
122765
122853
  failedLookupChecks = undefined;
122766
122854
  startsWithPathChecks = undefined;
122767
122855
  isInDirectoryChecks = undefined;
122768
122856
  affectingPathChecks = undefined;
122857
+ affectingPathChecksForFile = undefined;
122769
122858
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122770
122859
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122771
- clearPerDirectoryResolutions();
122860
+ moduleResolutionCache.clear();
122861
+ typeReferenceDirectiveResolutionCache.clear();
122862
+ impliedFormatPackageJsons.clear();
122772
122863
  hasChangedAutomaticTypeDirectiveNames = false;
122773
122864
  }
122774
122865
  function startRecordingFilesWithChangedResolutions() {
@@ -122800,15 +122891,40 @@ var ts;
122800
122891
  return function (path) { return (!!collected && collected.has(path)) ||
122801
122892
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
122802
122893
  }
122803
- function clearPerDirectoryResolutions() {
122804
- moduleResolutionCache.clear();
122805
- typeReferenceDirectiveResolutionCache.clear();
122806
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122807
- nonRelativeExternalModuleResolutions.clear();
122894
+ function startCachingPerDirectoryResolution() {
122895
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
122896
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
122808
122897
  }
122809
- function finishCachingPerDirectoryResolution() {
122898
+ function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
122810
122899
  filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
122811
- clearPerDirectoryResolutions();
122900
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122901
+ nonRelativeExternalModuleResolutions.clear();
122902
+ // Update file watches
122903
+ if (newProgram !== oldProgram) {
122904
+ newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
122905
+ var _a, _b, _c;
122906
+ var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
122907
+ var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
122908
+ for (var i = existing.length; i < expected; i++) {
122909
+ createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false);
122910
+ }
122911
+ if (existing.length > expected) {
122912
+ for (var i = expected; i < existing.length; i++) {
122913
+ fileWatchesOfAffectingLocations.get(existing[i]).files--;
122914
+ }
122915
+ }
122916
+ if (expected)
122917
+ impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
122918
+ else
122919
+ impliedFormatPackageJsons.delete(newFile.path);
122920
+ });
122921
+ impliedFormatPackageJsons.forEach(function (existing, path) {
122922
+ if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
122923
+ existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
122924
+ impliedFormatPackageJsons.delete(path);
122925
+ }
122926
+ });
122927
+ }
122812
122928
  directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
122813
122929
  if (watcher.refCount === 0) {
122814
122930
  directoryWatchesOfFailedLookups.delete(path);
@@ -122816,7 +122932,7 @@ var ts;
122816
122932
  }
122817
122933
  });
122818
122934
  fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
122819
- if (watcher.refCount === 0) {
122935
+ if (watcher.files === 0 && watcher.resolutions === 0) {
122820
122936
  fileWatchesOfAffectingLocations.delete(path);
122821
122937
  watcher.watcher.close();
122822
122938
  // Ensure when watching symlinked package.json, we can close the actual file watcher only once
@@ -123047,7 +123163,7 @@ var ts;
123047
123163
  }
123048
123164
  // If the directory is node_modules use it to watch, always watch it recursively
123049
123165
  if (ts.isNodeModulesDirectory(dirPath)) {
123050
- return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
123166
+ return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
123051
123167
  }
123052
123168
  var nonRecursive = true;
123053
123169
  // Use some ancestor of the root directory
@@ -123065,7 +123181,7 @@ var ts;
123065
123181
  dir = ts.getDirectoryPath(dir);
123066
123182
  }
123067
123183
  }
123068
- return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
123184
+ return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
123069
123185
  }
123070
123186
  function isPathWithDefaultFailedLookupExtension(path) {
123071
123187
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
@@ -123136,46 +123252,58 @@ var ts;
123136
123252
  // Watch package json
123137
123253
  for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
123138
123254
  var affectingLocation = affectingLocations_1[_i];
123139
- createFileWatcherOfAffectingLocation(affectingLocation);
123255
+ createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
123140
123256
  }
123141
123257
  }
123142
- function createFileWatcherOfAffectingLocation(affectingLocation) {
123143
- var path = resolutionHost.toPath(affectingLocation);
123144
- var fileWatcher = fileWatchesOfAffectingLocations.get(path);
123258
+ function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
123259
+ var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
123145
123260
  if (fileWatcher) {
123146
- fileWatcher.refCount++;
123261
+ if (forResolution)
123262
+ fileWatcher.resolutions++;
123263
+ else
123264
+ fileWatcher.files++;
123147
123265
  return;
123148
123266
  }
123149
123267
  var locationToWatch = affectingLocation;
123150
- var locationToWatchPath = path;
123151
123268
  if (resolutionHost.realpath) {
123152
123269
  locationToWatch = resolutionHost.realpath(affectingLocation);
123153
- locationToWatchPath = resolutionHost.toPath(locationToWatch);
123154
- if (path !== locationToWatchPath) {
123155
- var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
123270
+ if (affectingLocation !== locationToWatch) {
123271
+ var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch);
123156
123272
  if (fileWatcher_1) {
123157
- fileWatcher_1.refCount++;
123158
- fileWatcher_1.paths.add(path);
123159
- fileWatchesOfAffectingLocations.set(path, fileWatcher_1);
123273
+ if (forResolution)
123274
+ fileWatcher_1.resolutions++;
123275
+ else
123276
+ fileWatcher_1.files++;
123277
+ fileWatcher_1.paths.add(affectingLocation);
123278
+ fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1);
123160
123279
  return;
123161
123280
  }
123162
123281
  }
123163
123282
  }
123164
123283
  var paths = new ts.Set();
123165
- paths.add(locationToWatchPath);
123284
+ paths.add(locationToWatch);
123166
123285
  var watcher = {
123167
- watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
123168
- cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
123169
- paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); });
123170
- resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123171
- }),
123172
- refCount: 1,
123286
+ watcher: canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
123287
+ resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
123288
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
123289
+ paths.forEach(function (path) {
123290
+ var _a;
123291
+ if (watcher.resolutions)
123292
+ (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
123293
+ if (watcher.files)
123294
+ (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
123295
+ (_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
123296
+ });
123297
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123298
+ }) : ts.noopFileWatcher,
123299
+ resolutions: forResolution ? 1 : 0,
123300
+ files: forResolution ? 0 : 1,
123173
123301
  paths: paths,
123174
123302
  };
123175
- fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
123176
- if (path !== locationToWatchPath) {
123177
- fileWatchesOfAffectingLocations.set(path, watcher);
123178
- paths.add(path);
123303
+ fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
123304
+ if (affectingLocation !== locationToWatch) {
123305
+ fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
123306
+ paths.add(affectingLocation);
123179
123307
  }
123180
123308
  }
123181
123309
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
@@ -123243,8 +123371,8 @@ var ts;
123243
123371
  }
123244
123372
  for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
123245
123373
  var affectingLocation = affectingLocations_2[_a];
123246
- var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
123247
- watcher.refCount--;
123374
+ var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
123375
+ watcher.resolutions--;
123248
123376
  }
123249
123377
  }
123250
123378
  function removeDirectoryWatcher(dirPath) {
@@ -123298,7 +123426,7 @@ var ts;
123298
123426
  resolution.isInvalidated = invalidated = true;
123299
123427
  for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
123300
123428
  var containingFilePath = _b[_a];
123301
- (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
123429
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
123302
123430
  // When its a file with inferred types resolution, invalidate type reference directive resolution
123303
123431
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
123304
123432
  }
@@ -123365,10 +123493,25 @@ var ts;
123365
123493
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123366
123494
  }
123367
123495
  function invalidateResolutionsOfFailedLookupLocations() {
123496
+ var _a;
123497
+ var invalidated = false;
123498
+ if (affectingPathChecksForFile) {
123499
+ (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
123500
+ if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
123501
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
123502
+ invalidated = true;
123503
+ }
123504
+ });
123505
+ affectingPathChecksForFile = undefined;
123506
+ }
123368
123507
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
123369
- return false;
123508
+ return invalidated;
123509
+ }
123510
+ invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
123511
+ var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
123512
+ if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
123513
+ packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; });
123370
123514
  }
123371
- var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
123372
123515
  failedLookupChecks = undefined;
123373
123516
  startsWithPathChecks = undefined;
123374
123517
  isInDirectoryChecks = undefined;
@@ -123381,17 +123524,15 @@ var ts;
123381
123524
  return true;
123382
123525
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
123383
123526
  return false;
123384
- return resolution.failedLookupLocations.some(function (location) {
123385
- var locationPath = resolutionHost.toPath(location);
123386
- return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
123387
- ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
123388
- ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
123389
- });
123527
+ return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); });
123528
+ }
123529
+ function isInvalidatedFailedLookup(locationPath) {
123530
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
123531
+ ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
123532
+ ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
123390
123533
  }
123391
123534
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
123392
- return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
123393
- return affectingPathChecks.has(resolutionHost.toPath(location));
123394
- });
123535
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
123395
123536
  }
123396
123537
  function closeTypeRootsWatch() {
123397
123538
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -123457,7 +123598,7 @@ var ts;
123457
123598
  function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
123458
123599
  var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
123459
123600
  var dirPath = resolutionHost.toPath(dir);
123460
- return dirPath === rootPath || canWatchDirectory(dirPath);
123601
+ return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
123461
123602
  }
123462
123603
  }
123463
123604
  ts.createResolutionCache = createResolutionCache;
@@ -124430,23 +124571,46 @@ var ts;
124430
124571
  var file = _c[_i];
124431
124572
  write("" + toFileName(file, relativeFileName));
124432
124573
  (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
124433
- (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
124574
+ (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
124434
124575
  }
124435
124576
  }
124436
124577
  ts.explainFiles = explainFiles;
124437
- function explainIfFileIsRedirect(file, fileNameConvertor) {
124578
+ function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
124579
+ var _a;
124438
124580
  var result;
124439
124581
  if (file.path !== file.resolvedPath) {
124440
- (result || (result = [])).push(ts.chainDiagnosticMessages(
124582
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124441
124583
  /*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
124442
124584
  }
124443
124585
  if (file.redirectInfo) {
124444
- (result || (result = [])).push(ts.chainDiagnosticMessages(
124586
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124445
124587
  /*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
124446
124588
  }
124589
+ if (ts.isExternalOrCommonJsModule(file)) {
124590
+ switch (file.impliedNodeFormat) {
124591
+ case ts.ModuleKind.ESNext:
124592
+ if (file.packageJsonScope) {
124593
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124594
+ /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
124595
+ }
124596
+ break;
124597
+ case ts.ModuleKind.CommonJS:
124598
+ if (file.packageJsonScope) {
124599
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124600
+ /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
124601
+ ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
124602
+ ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
124603
+ }
124604
+ else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
124605
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124606
+ /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
124607
+ }
124608
+ break;
124609
+ }
124610
+ }
124447
124611
  return result;
124448
124612
  }
124449
- ts.explainIfFileIsRedirect = explainIfFileIsRedirect;
124613
+ ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat;
124450
124614
  function getMatchedFileSpec(program, fileName) {
124451
124615
  var _a;
124452
124616
  var configFile = program.getCompilerOptions().configFile;
@@ -124656,6 +124820,7 @@ var ts;
124656
124820
  MissingFile: "Missing file",
124657
124821
  WildcardDirectory: "Wild card directory",
124658
124822
  FailedLookupLocations: "Failed Lookup Locations",
124823
+ AffectingFileLocation: "File location affecting resolution",
124659
124824
  TypeRoots: "Type roots",
124660
124825
  ConfigFileOfReferencedProject: "Config file of referened project",
124661
124826
  ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
@@ -124979,7 +125144,7 @@ var ts;
124979
125144
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
124980
125145
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
124981
125146
  compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
124982
- compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); };
125147
+ compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); };
124983
125148
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
124984
125149
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
124985
125150
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -125013,6 +125178,9 @@ var ts;
125013
125178
  return host.resolveTypeReferenceDirectives.apply(host, args);
125014
125179
  }) :
125015
125180
  (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
125181
+ compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
125182
+ ts.maybeBind(host, host.getModuleResolutionCache) :
125183
+ (function () { return resolutionCache.getModuleResolutionCache(); });
125016
125184
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
125017
125185
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
125018
125186
  synchronizeProgram();
@@ -125115,8 +125283,9 @@ var ts;
125115
125283
  resolutionCache.startCachingPerDirectoryResolution();
125116
125284
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
125117
125285
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
125286
+ var oldProgram = getCurrentProgram();
125118
125287
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
125119
- resolutionCache.finishCachingPerDirectoryResolution();
125288
+ resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
125120
125289
  // Update watches
125121
125290
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
125122
125291
  if (needsUpdateInTypeRootWatch) {
@@ -125198,9 +125367,6 @@ var ts;
125198
125367
  sourceFilesCache.set(path, false);
125199
125368
  }
125200
125369
  }
125201
- if (sourceFile) {
125202
- sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
125203
- }
125204
125370
  return sourceFile;
125205
125371
  }
125206
125372
  return hostSourceFile.sourceFile;
@@ -125716,6 +125882,7 @@ var ts;
125716
125882
  compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
125717
125883
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
125718
125884
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
125885
+ compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
125719
125886
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
125720
125887
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
125721
125888
  if (!compilerHost.resolveModuleNames) {
@@ -137934,60 +138101,64 @@ var ts;
137934
138101
  }
137935
138102
  return settingsOrHost;
137936
138103
  }
137937
- function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
138104
+ function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
137938
138105
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
137939
138106
  var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
137940
- return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
138107
+ return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
137941
138108
  }
137942
- function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
137943
- return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
138109
+ function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
138110
+ return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions);
137944
138111
  }
137945
- function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
138112
+ function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
137946
138113
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
137947
138114
  var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
137948
- return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
138115
+ return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
137949
138116
  }
137950
- function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
137951
- return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
138117
+ function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
138118
+ return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions);
137952
138119
  }
137953
138120
  function getDocumentRegistryEntry(bucketEntry, scriptKind) {
137954
138121
  var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided"));
137955
138122
  ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry);
137956
138123
  return entry;
137957
138124
  }
137958
- function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
138125
+ function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) {
137959
138126
  var _a, _b, _c, _d;
137960
138127
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
137961
138128
  var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
137962
138129
  var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
137963
138130
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
137964
- var sourceFileOptions = {
137965
- languageVersion: scriptTarget,
137966
- impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings),
137967
- setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
137968
- };
138131
+ var sourceFileOptions = typeof languageVersionOrOptions === "object" ?
138132
+ languageVersionOrOptions :
138133
+ {
138134
+ languageVersion: scriptTarget,
138135
+ impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings),
138136
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
138137
+ };
138138
+ sourceFileOptions.languageVersion = scriptTarget;
137969
138139
  var oldBucketCount = buckets.size;
137970
- var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
138140
+ var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat);
138141
+ var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); });
137971
138142
  if (ts.tracing) {
137972
138143
  if (buckets.size > oldBucketCount) {
137973
138144
  // It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
137974
138145
  // perhaps they are for two projects that don't have any overlap.
137975
138146
  // Bonus: these events can help us interpret the more interesting event below.
137976
- ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
138147
+ ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode });
137977
138148
  }
137978
138149
  // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
137979
138150
  // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
137980
138151
  // Skip .d.ts files to reduce noise (should also cover most of node_modules).
137981
138152
  var otherBucketKey = !ts.isDeclarationFileName(path) &&
137982
- ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
138153
+ ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; });
137983
138154
  if (otherBucketKey) {
137984
- ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
138155
+ ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode });
137985
138156
  }
137986
138157
  }
137987
138158
  var bucketEntry = bucket.get(path);
137988
138159
  var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
137989
138160
  if (!entry && externalCache) {
137990
- var sourceFile = externalCache.getDocument(key, path);
138161
+ var sourceFile = externalCache.getDocument(keyWithMode, path);
137991
138162
  if (sourceFile) {
137992
138163
  ts.Debug.assert(acquiring);
137993
138164
  entry = {
@@ -138001,7 +138172,7 @@ var ts;
138001
138172
  // Have never seen this file with these settings. Create a new source file for it.
138002
138173
  var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
138003
138174
  if (externalCache) {
138004
- externalCache.setDocument(key, path, sourceFile);
138175
+ externalCache.setDocument(keyWithMode, path, sourceFile);
138005
138176
  }
138006
138177
  entry = {
138007
138178
  sourceFile: sourceFile,
@@ -138016,7 +138187,7 @@ var ts;
138016
138187
  if (entry.sourceFile.version !== version) {
138017
138188
  entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217
138018
138189
  if (externalCache) {
138019
- externalCache.setDocument(key, path, entry.sourceFile);
138190
+ externalCache.setDocument(keyWithMode, path, entry.sourceFile);
138020
138191
  }
138021
138192
  }
138022
138193
  // If we're acquiring, then this is the first time this LS is asking for this document.
@@ -138045,13 +138216,13 @@ var ts;
138045
138216
  }
138046
138217
  }
138047
138218
  }
138048
- function releaseDocument(fileName, compilationSettings, scriptKind) {
138219
+ function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) {
138049
138220
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
138050
138221
  var key = getKeyForCompilationSettings(compilationSettings);
138051
- return releaseDocumentWithKey(path, key, scriptKind);
138222
+ return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat);
138052
138223
  }
138053
- function releaseDocumentWithKey(path, key, scriptKind) {
138054
- var bucket = ts.Debug.checkDefined(buckets.get(key));
138224
+ function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) {
138225
+ var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat)));
138055
138226
  var bucketEntry = bucket.get(path);
138056
138227
  var entry = getDocumentRegistryEntry(bucketEntry, scriptKind);
138057
138228
  entry.languageServiceRefCount--;
@@ -138108,6 +138279,9 @@ var ts;
138108
138279
  function getKeyForCompilationSettings(settings) {
138109
138280
  return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined);
138110
138281
  }
138282
+ function getDocumentRegistryBucketKeyWithMode(key, mode) {
138283
+ return (mode ? key + "|" + mode : key);
138284
+ }
138111
138285
  })(ts || (ts = {}));
138112
138286
  /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */
138113
138287
  /* @internal */
@@ -167351,12 +167525,12 @@ var ts;
167351
167525
  // not part of the new program.
167352
167526
  function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
167353
167527
  var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
167354
- documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind);
167528
+ documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
167355
167529
  }
167356
- function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) {
167357
- return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile);
167530
+ function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
167531
+ return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
167358
167532
  }
167359
- function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) {
167533
+ function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) {
167360
167534
  ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
167361
167535
  // The program is asking for this file, check first if the host can locate it.
167362
167536
  // If the host can not locate the file, then it does not exist. return undefined
@@ -167399,17 +167573,17 @@ var ts;
167399
167573
  // file's script kind, i.e. in one project some file is treated as ".ts"
167400
167574
  // and in another as ".js"
167401
167575
  if (scriptKind === oldSourceFile.scriptKind) {
167402
- return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
167576
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
167403
167577
  }
167404
167578
  else {
167405
167579
  // Release old source file and fall through to aquire new file with new script kind
167406
- documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind);
167580
+ documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
167407
167581
  }
167408
167582
  }
167409
167583
  // We didn't already have the file. Fall through and acquire it from the registry.
167410
167584
  }
167411
167585
  // Could not find this file in the old program, create a new SourceFile for it.
167412
- return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
167586
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
167413
167587
  }
167414
167588
  }
167415
167589
  // TODO: GH#18217 frequently asserted as defined
@@ -167488,7 +167662,7 @@ var ts;
167488
167662
  // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
167489
167663
  var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
167490
167664
  ts.forEach(program.getSourceFiles(), function (f) {
167491
- return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind);
167665
+ return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat);
167492
167666
  });
167493
167667
  program = undefined; // TODO: GH#18217
167494
167668
  }
@@ -168405,6 +168579,7 @@ var ts;
168405
168579
  getEmitOutput: getEmitOutput,
168406
168580
  getNonBoundSourceFile: getNonBoundSourceFile,
168407
168581
  getProgram: getProgram,
168582
+ getCurrentProgram: function () { return program; },
168408
168583
  getAutoImportProvider: getAutoImportProvider,
168409
168584
  updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
168410
168585
  getApplicableRefactors: getApplicableRefactors,
@@ -171622,7 +171797,7 @@ var ts;
171622
171797
  };
171623
171798
  /*@internal*/
171624
171799
  Project.prototype.watchAffectingFileLocation = function (file, cb) {
171625
- return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.PackageJson, this);
171800
+ return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.AffectingFileLocation, this);
171626
171801
  };
171627
171802
  /*@internal*/
171628
171803
  Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () {
@@ -172159,7 +172334,7 @@ var ts;
172159
172334
  };
172160
172335
  Project.prototype.updateGraphWorker = function () {
172161
172336
  var _this = this;
172162
- var oldProgram = this.program;
172337
+ var oldProgram = this.languageService.getCurrentProgram();
172163
172338
  ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
172164
172339
  this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName());
172165
172340
  var start = ts.timestamp();
@@ -172168,7 +172343,7 @@ var ts;
172168
172343
  this.program = this.languageService.getProgram(); // TODO: GH#18217
172169
172344
  this.dirty = false;
172170
172345
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
172171
- this.resolutionCache.finishCachingPerDirectoryResolution();
172346
+ this.resolutionCache.finishCachingPerDirectoryResolution(this.program, oldProgram);
172172
172347
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
172173
172348
  ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
172174
172349
  // bump up the version if
@@ -174626,7 +174801,7 @@ var ts;
174626
174801
  // created when any of the script infos are added as root of inferred project
174627
174802
  if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) {
174628
174803
  // If we cannot watch config file existence without configured project, close the configured file watcher
174629
- if (!ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath))) {
174804
+ if (!ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath))) {
174630
174805
  configFileExistenceInfo.watcher.close();
174631
174806
  configFileExistenceInfo.watcher = noopConfigFileWatcher;
174632
174807
  }
@@ -174706,7 +174881,7 @@ var ts;
174706
174881
  // Set this file as the root of inferred project
174707
174882
  (configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = new ts.Map())).set(info.path, true);
174708
174883
  // If there is no configured project for this config file, add the file watcher
174709
- configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath)) ?
174884
+ configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath)) ?
174710
174885
  _this.watchFactory.watchFile(configFileName, function (_filename, eventKind) { return _this.onConfigFileChanged(canonicalConfigFilePath, eventKind); }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ConfigFileForInferredRoot) :
174711
174886
  noopConfigFileWatcher);
174712
174887
  });