@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/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-insiders.20220728";
112
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220730";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -5722,10 +5722,8 @@ var ts;
5722
5722
  TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5723
5723
  TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5724
5724
  TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5725
- // Please leave this as 1 << 29.
5726
- // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5727
- // It is a good reminder of how much room we have left
5728
- TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
5725
+ TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression";
5726
+ TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags";
5729
5727
  // Assertions
5730
5728
  // - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
5731
5729
  TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript";
@@ -5744,23 +5742,23 @@ var ts;
5744
5742
  // Scope Exclusions
5745
5743
  // - Bitmasks that exclude flags from propagating out of a specific context
5746
5744
  // into the subtree flags of their container.
5747
- TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5748
- TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5749
- TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5750
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5751
- TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5752
- TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5753
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5754
- TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5755
- TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5756
- TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5745
+ TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes";
5746
+ TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes";
5747
+ TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes";
5748
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes";
5749
+ TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes";
5750
+ TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes";
5751
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes";
5752
+ TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes";
5753
+ TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes";
5754
+ TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes";
5757
5755
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5758
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5759
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5760
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5761
- TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5762
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5763
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5756
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes";
5757
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes";
5758
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes";
5759
+ TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes";
5760
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes";
5761
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes";
5764
5762
  TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5765
5763
  // Propagating flags
5766
5764
  // - Bitmasks for flags that should propagate from a child
@@ -8573,6 +8571,10 @@ var ts;
8573
8571
  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."),
8574
8572
  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`."),
8575
8573
  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 '**/*'"),
8574
+ 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\""),
8575
+ 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\""),
8576
+ 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\""),
8577
+ 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"),
8576
8578
  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."),
8577
8579
  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."),
8578
8580
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
@@ -24099,7 +24101,7 @@ var ts;
24099
24101
  propagateChildFlags(node.expression) |
24100
24102
  (ts.isIdentifier(node.name) ?
24101
24103
  propagateIdentifierNameFlags(node.name) :
24102
- propagateChildFlags(node.name));
24104
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24103
24105
  if (ts.isSuperKeyword(expression)) {
24104
24106
  // super method calls require a lexical 'this'
24105
24107
  // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
@@ -24132,7 +24134,7 @@ var ts;
24132
24134
  propagateChildFlags(node.questionDotToken) |
24133
24135
  (ts.isIdentifier(node.name) ?
24134
24136
  propagateIdentifierNameFlags(node.name) :
24135
- propagateChildFlags(node.name));
24137
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24136
24138
  return node;
24137
24139
  }
24138
24140
  // @api
@@ -24536,6 +24538,9 @@ var ts;
24536
24538
  else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
24537
24539
  node.transformFlags |= 16 /* ContainsES2021 */;
24538
24540
  }
24541
+ if (operatorKind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
24542
+ node.transformFlags |= 536870912 /* ContainsPrivateIdentifierInExpression */;
24543
+ }
24539
24544
  return node;
24540
24545
  }
24541
24546
  function propagateAssignmentPatternFlags(node) {
@@ -27490,29 +27495,29 @@ var ts;
27490
27495
  case 208 /* CallExpression */:
27491
27496
  case 209 /* NewExpression */:
27492
27497
  case 204 /* ArrayLiteralExpression */:
27493
- return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27498
+ return -2147450880 /* ArrayLiteralOrCallOrNewExcludes */;
27494
27499
  case 261 /* ModuleDeclaration */:
27495
- return 742678528 /* ModuleExcludes */;
27500
+ return -1941676032 /* ModuleExcludes */;
27496
27501
  case 164 /* Parameter */:
27497
- return 536870912 /* ParameterExcludes */;
27502
+ return -2147483648 /* ParameterExcludes */;
27498
27503
  case 214 /* ArrowFunction */:
27499
- return 612179968 /* ArrowFunctionExcludes */;
27504
+ return -2072174592 /* ArrowFunctionExcludes */;
27500
27505
  case 213 /* FunctionExpression */:
27501
27506
  case 256 /* FunctionDeclaration */:
27502
- return 746414080 /* FunctionExcludes */;
27507
+ return -1937940480 /* FunctionExcludes */;
27503
27508
  case 255 /* VariableDeclarationList */:
27504
- return 537460736 /* VariableDeclarationListExcludes */;
27509
+ return -2146893824 /* VariableDeclarationListExcludes */;
27505
27510
  case 257 /* ClassDeclaration */:
27506
27511
  case 226 /* ClassExpression */:
27507
- return 537010176 /* ClassExcludes */;
27512
+ return -2147344384 /* ClassExcludes */;
27508
27513
  case 171 /* Constructor */:
27509
- return 746405888 /* ConstructorExcludes */;
27514
+ return -1937948672 /* ConstructorExcludes */;
27510
27515
  case 167 /* PropertyDeclaration */:
27511
- return 671105024 /* PropertyExcludes */;
27516
+ return -2013249536 /* PropertyExcludes */;
27512
27517
  case 169 /* MethodDeclaration */:
27513
27518
  case 172 /* GetAccessor */:
27514
27519
  case 173 /* SetAccessor */:
27515
- return 679297024 /* MethodOrAccessorExcludes */;
27520
+ return -2005057536 /* MethodOrAccessorExcludes */;
27516
27521
  case 130 /* AnyKeyword */:
27517
27522
  case 147 /* NumberKeyword */:
27518
27523
  case 158 /* BigIntKeyword */:
@@ -27532,23 +27537,23 @@ var ts;
27532
27537
  case 259 /* TypeAliasDeclaration */:
27533
27538
  return -2 /* TypeExcludes */;
27534
27539
  case 205 /* ObjectLiteralExpression */:
27535
- return 537075712 /* ObjectLiteralExcludes */;
27540
+ return -2147278848 /* ObjectLiteralExcludes */;
27536
27541
  case 292 /* CatchClause */:
27537
- return 536936448 /* CatchClauseExcludes */;
27542
+ return -2147418112 /* CatchClauseExcludes */;
27538
27543
  case 201 /* ObjectBindingPattern */:
27539
27544
  case 202 /* ArrayBindingPattern */:
27540
- return 536903680 /* BindingPatternExcludes */;
27545
+ return -2147450880 /* BindingPatternExcludes */;
27541
27546
  case 211 /* TypeAssertionExpression */:
27542
27547
  case 229 /* AsExpression */:
27543
27548
  case 350 /* PartiallyEmittedExpression */:
27544
27549
  case 212 /* ParenthesizedExpression */:
27545
27550
  case 106 /* SuperKeyword */:
27546
- return 536870912 /* OuterExpressionExcludes */;
27551
+ return -2147483648 /* OuterExpressionExcludes */;
27547
27552
  case 206 /* PropertyAccessExpression */:
27548
27553
  case 207 /* ElementAccessExpression */:
27549
- return 536870912 /* PropertyAccessExcludes */;
27554
+ return -2147483648 /* PropertyAccessExcludes */;
27550
27555
  default:
27551
- return 536870912 /* NodeExcludes */;
27556
+ return -2147483648 /* NodeExcludes */;
27552
27557
  }
27553
27558
  }
27554
27559
  ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
@@ -43247,7 +43252,7 @@ var ts;
43247
43252
  ts.createCacheWithRedirects = createCacheWithRedirects;
43248
43253
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
43249
43254
  var cache;
43250
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
43255
+ return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
43251
43256
  function getPackageJsonInfo(packageJsonPath) {
43252
43257
  return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
43253
43258
  }
@@ -43261,6 +43266,9 @@ var ts;
43261
43266
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
43262
43267
  return iter ? ts.arrayFrom(iter) : [];
43263
43268
  }
43269
+ function getInternalMap() {
43270
+ return cache;
43271
+ }
43264
43272
  }
43265
43273
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
43266
43274
  var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
@@ -43364,15 +43372,18 @@ var ts;
43364
43372
  }
43365
43373
  ts.zipToModeAwareCache = zipToModeAwareCache;
43366
43374
  function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
43367
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43375
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43368
43376
  moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
43369
43377
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
43370
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } });
43378
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43371
43379
  function clear() {
43372
- preDirectoryResolutionCache.clear();
43373
- moduleNameToDirectoryMap.clear();
43380
+ clearAllExceptPackageJsonInfoCache();
43374
43381
  packageJsonInfoCache.clear();
43375
43382
  }
43383
+ function clearAllExceptPackageJsonInfoCache() {
43384
+ perDirectoryResolutionCache.clear();
43385
+ moduleNameToDirectoryMap.clear();
43386
+ }
43376
43387
  function update(options) {
43377
43388
  updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
43378
43389
  }
@@ -43450,11 +43461,14 @@ var ts;
43450
43461
  function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
43451
43462
  var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43452
43463
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
43453
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear });
43464
+ return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43454
43465
  function clear() {
43455
- preDirectoryResolutionCache.clear();
43466
+ clearAllExceptPackageJsonInfoCache();
43456
43467
  packageJsonInfoCache.clear();
43457
43468
  }
43469
+ function clearAllExceptPackageJsonInfoCache() {
43470
+ preDirectoryResolutionCache.clear();
43471
+ }
43458
43472
  }
43459
43473
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
43460
43474
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
@@ -52895,6 +52909,12 @@ var ts;
52895
52909
  return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
52896
52910
  }
52897
52911
  function typeToTypeNodeHelper(type, context) {
52912
+ var savedFlags = context.flags;
52913
+ var typeNode = typeToTypeNodeWorker(type, context);
52914
+ context.flags = savedFlags;
52915
+ return typeNode;
52916
+ }
52917
+ function typeToTypeNodeWorker(type, context) {
52898
52918
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
52899
52919
  cancellationToken.throwIfCancellationRequested();
52900
52920
  }
@@ -80788,7 +80808,7 @@ var ts;
80788
80808
  error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
80789
80809
  }
80790
80810
  }
80791
- if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
80811
+ if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) {
80792
80812
  error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
80793
80813
  }
80794
80814
  if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
@@ -96593,39 +96613,72 @@ var ts;
96593
96613
  function visitClassDeclaration(node) {
96594
96614
  if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
96595
96615
  return ts.visitEachChild(node, visitor, context);
96596
- var classStatement = ts.hasDecorators(node) ?
96597
- createClassDeclarationHeadWithDecorators(node, node.name) :
96598
- createClassDeclarationHeadWithoutDecorators(node, node.name);
96599
- var statements = [classStatement];
96600
- // Write any decorators of the node.
96601
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
96602
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
96603
- addConstructorDecorationStatement(statements, node);
96616
+ var statements = ts.hasDecorators(node) ?
96617
+ transformClassDeclarationWithClassDecorators(node, node.name) :
96618
+ transformClassDeclarationWithoutClassDecorators(node, node.name);
96604
96619
  if (statements.length > 1) {
96605
96620
  // Add a DeclarationMarker as a marker for the end of the declaration
96606
96621
  statements.push(factory.createEndOfDeclarationMarker(node));
96607
- ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
96622
+ ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* HasEndOfDeclarationMarker */);
96608
96623
  }
96609
96624
  return ts.singleOrMany(statements);
96610
96625
  }
96626
+ function decoratorContainsPrivateIdentifierInExpression(decorator) {
96627
+ return !!(decorator.transformFlags & 536870912 /* ContainsPrivateIdentifierInExpression */);
96628
+ }
96629
+ function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) {
96630
+ return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression);
96631
+ }
96632
+ function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) {
96633
+ for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
96634
+ var member = _a[_i];
96635
+ if (!ts.canHaveDecorators(member))
96636
+ continue;
96637
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96638
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression))
96639
+ return true;
96640
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression))
96641
+ return true;
96642
+ }
96643
+ return false;
96644
+ }
96645
+ function transformDecoratorsOfClassElements(node, members) {
96646
+ var decorationStatements = [];
96647
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false);
96648
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true);
96649
+ if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) {
96650
+ members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [
96651
+ factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true))
96652
+ ], false)), members);
96653
+ decorationStatements = undefined;
96654
+ }
96655
+ return { decorationStatements: decorationStatements, members: members };
96656
+ }
96611
96657
  /**
96612
96658
  * Transforms a non-decorated class declaration.
96613
96659
  *
96614
96660
  * @param node A ClassDeclaration node.
96615
96661
  * @param name The name of the class.
96616
96662
  */
96617
- function createClassDeclarationHeadWithoutDecorators(node, name) {
96663
+ function transformClassDeclarationWithoutClassDecorators(node, name) {
96618
96664
  // ${modifiers} class ${name} ${heritageClauses} {
96619
96665
  // ${members}
96620
96666
  // }
96621
- return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name,
96622
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96667
+ var _a;
96668
+ var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
96669
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96670
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96671
+ var decorationStatements = [];
96672
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96673
+ var updated = factory.updateClassDeclaration(node, modifiers, name,
96674
+ /*typeParameters*/ undefined, heritageClauses, members);
96675
+ return ts.addRange([updated], decorationStatements);
96623
96676
  }
96624
96677
  /**
96625
96678
  * Transforms a decorated class declaration and appends the resulting statements. If
96626
96679
  * the class requires an alias to avoid issues with double-binding, the alias is returned.
96627
96680
  */
96628
- function createClassDeclarationHeadWithDecorators(node, name) {
96681
+ function transformClassDeclarationWithClassDecorators(node, name) {
96629
96682
  // When we emit an ES6 class that has a class decorator, we must tailor the
96630
96683
  // emit to certain specific cases.
96631
96684
  //
@@ -96711,6 +96764,7 @@ var ts;
96711
96764
  // | var C_1;
96712
96765
  // ---------------------------------------------------------------------
96713
96766
  //
96767
+ var _a;
96714
96768
  var location = ts.moveRangePastModifiers(node);
96715
96769
  var classAlias = getClassAliasIfNeeded(node);
96716
96770
  // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
@@ -96723,7 +96777,11 @@ var ts;
96723
96777
  // }
96724
96778
  var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96725
96779
  var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96726
- var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
96780
+ var decorationStatements = [];
96781
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96782
+ var classExpression = factory.createClassExpression(
96783
+ /*modifiers*/ undefined, name,
96784
+ /*typeParameters*/ undefined, heritageClauses, members);
96727
96785
  ts.setOriginalNode(classExpression, node);
96728
96786
  ts.setTextRange(classExpression, location);
96729
96787
  // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
@@ -96737,7 +96795,10 @@ var ts;
96737
96795
  ts.setOriginalNode(statement, node);
96738
96796
  ts.setTextRange(statement, location);
96739
96797
  ts.setCommentRange(statement, node);
96740
- return statement;
96798
+ var statements = [statement];
96799
+ ts.addRange(statements, decorationStatements);
96800
+ addConstructorDecorationStatement(statements, node);
96801
+ return statements;
96741
96802
  }
96742
96803
  function visitClassExpression(node) {
96743
96804
  // Legacy decorators were not supported on class expressions
@@ -117654,6 +117715,12 @@ var ts;
117654
117715
  * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
117655
117716
  */
117656
117717
  function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
117718
+ var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
117719
+ return typeof result === "object" ? result.impliedNodeFormat : result;
117720
+ }
117721
+ ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
117722
+ /*@internal*/
117723
+ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
117657
117724
  switch (ts.getEmitModuleResolutionKind(options)) {
117658
117725
  case ts.ModuleResolutionKind.Node16:
117659
117726
  case ts.ModuleResolutionKind.NodeNext:
@@ -117665,11 +117732,16 @@ var ts;
117665
117732
  return undefined;
117666
117733
  }
117667
117734
  function lookupFromPackageJson() {
117668
- var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
117669
- return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117735
+ var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
117736
+ var packageJsonLocations = [];
117737
+ state.failedLookupLocations = packageJsonLocations;
117738
+ state.affectingLocations = packageJsonLocations;
117739
+ var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
117740
+ var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117741
+ return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
117670
117742
  }
117671
117743
  }
117672
- ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
117744
+ ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
117673
117745
  /** @internal */
117674
117746
  ts.plainJSErrors = new ts.Set([
117675
117747
  // binder errors
@@ -117994,7 +118066,7 @@ var ts;
117994
118066
  for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
117995
118067
  var oldSourceFile = oldSourceFiles_1[_i];
117996
118068
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
117997
- if (shouldCreateNewSourceFile || !newFile ||
118069
+ if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
117998
118070
  // old file wasn't redirect but new file is
117999
118071
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
118000
118072
  host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
@@ -118387,7 +118459,7 @@ var ts;
118387
118459
  });
118388
118460
  }
118389
118461
  function tryReuseStructureFromOldProgram() {
118390
- var _a;
118462
+ var _a, _b;
118391
118463
  if (!oldProgram) {
118392
118464
  return 0 /* Not */;
118393
118465
  }
@@ -118428,12 +118500,15 @@ var ts;
118428
118500
  var seenPackageNames = new ts.Map();
118429
118501
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
118430
118502
  var oldSourceFile = oldSourceFiles_2[_i];
118503
+ var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
118431
118504
  var newSourceFile = host.getSourceFileByPath
118432
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
118433
- : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
118505
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
118506
+ : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
118434
118507
  if (!newSourceFile) {
118435
118508
  return 0 /* Not */;
118436
118509
  }
118510
+ newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
118511
+ newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
118437
118512
  ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
118438
118513
  var fileChanged = void 0;
118439
118514
  if (oldSourceFile.redirectInfo) {
@@ -118473,38 +118548,43 @@ var ts;
118473
118548
  seenPackageNames.set(packageName, newKind);
118474
118549
  }
118475
118550
  if (fileChanged) {
118551
+ if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
118552
+ structureIsReused = 1 /* SafeModules */;
118553
+ }
118476
118554
  // The `newSourceFile` object was created for the new program.
118477
- if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
118555
+ else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
118478
118556
  // 'lib' references has changed. Matches behavior in changesAffectModuleResolution
118479
118557
  structureIsReused = 1 /* SafeModules */;
118480
118558
  }
118481
- if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
118559
+ else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
118482
118560
  // value of no-default-lib has changed
118483
118561
  // this will affect if default library is injected into the list of files
118484
118562
  structureIsReused = 1 /* SafeModules */;
118485
118563
  }
118486
118564
  // check tripleslash references
118487
- if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
118565
+ else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
118488
118566
  // tripleslash references has changed
118489
118567
  structureIsReused = 1 /* SafeModules */;
118490
118568
  }
118491
- // check imports and module augmentations
118492
- collectExternalModuleReferences(newSourceFile);
118493
- if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
118494
- // imports has changed
118495
- structureIsReused = 1 /* SafeModules */;
118496
- }
118497
- if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
118498
- // moduleAugmentations has changed
118499
- structureIsReused = 1 /* SafeModules */;
118500
- }
118501
- if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
118502
- // dynamicImport has changed
118503
- structureIsReused = 1 /* SafeModules */;
118504
- }
118505
- if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
118506
- // 'types' references has changed
118507
- structureIsReused = 1 /* SafeModules */;
118569
+ else {
118570
+ // check imports and module augmentations
118571
+ collectExternalModuleReferences(newSourceFile);
118572
+ if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
118573
+ // imports has changed
118574
+ structureIsReused = 1 /* SafeModules */;
118575
+ }
118576
+ else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
118577
+ // moduleAugmentations has changed
118578
+ structureIsReused = 1 /* SafeModules */;
118579
+ }
118580
+ else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
118581
+ // dynamicImport has changed
118582
+ structureIsReused = 1 /* SafeModules */;
118583
+ }
118584
+ else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
118585
+ // 'types' references has changed
118586
+ structureIsReused = 1 /* SafeModules */;
118587
+ }
118508
118588
  }
118509
118589
  // tentatively approve the file
118510
118590
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
@@ -118522,18 +118602,18 @@ var ts;
118522
118602
  return structureIsReused;
118523
118603
  }
118524
118604
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
118525
- for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
118526
- var oldFile = oldSourceFiles_3[_b];
118605
+ for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
118606
+ var oldFile = oldSourceFiles_3[_c];
118527
118607
  if (!ts.contains(modifiedFiles, oldFile)) {
118528
- for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
118529
- var moduleName = _d[_c];
118608
+ for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
118609
+ var moduleName = _e[_d];
118530
118610
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
118531
118611
  }
118532
118612
  }
118533
118613
  }
118534
118614
  // try to verify results of module resolution
118535
- for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
118536
- var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
118615
+ for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
118616
+ var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
118537
118617
  var moduleNames = getModuleNames(newSourceFile);
118538
118618
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
118539
118619
  // ensure that module resolution results are still correct
@@ -118560,14 +118640,14 @@ var ts;
118560
118640
  if (structureIsReused !== 2 /* Completely */) {
118561
118641
  return structureIsReused;
118562
118642
  }
118563
- if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) {
118643
+ if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
118564
118644
  return 1 /* SafeModules */;
118565
118645
  }
118566
118646
  missingFilePaths = oldProgram.getMissingFilePaths();
118567
118647
  // update fileName -> file mapping
118568
118648
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
118569
- for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
118570
- var newSourceFile = newSourceFiles_1[_g];
118649
+ for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
118650
+ var newSourceFile = newSourceFiles_1[_h];
118571
118651
  filesByName.set(newSourceFile.path, newSourceFile);
118572
118652
  }
118573
118653
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -119357,6 +119437,7 @@ var ts;
119357
119437
  redirect.resolvedPath = resolvedPath;
119358
119438
  redirect.originalFileName = originalFileName;
119359
119439
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
119440
+ // TODO:" shkamat"
119360
119441
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
119361
119442
  Object.defineProperties(redirect, {
119362
119443
  id: {
@@ -119385,14 +119466,14 @@ var ts;
119385
119466
  // 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
119386
119467
  // 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
119387
119468
  // 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.
119388
- var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
119389
- return {
119390
- languageVersion: ts.getEmitScriptTarget(options),
119391
- impliedNodeFormat: impliedNodeFormat,
119392
- setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
119393
- };
119469
+ var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
119470
+ var languageVersion = ts.getEmitScriptTarget(options);
119471
+ var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
119472
+ return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) :
119473
+ { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
119394
119474
  }
119395
119475
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
119476
+ var _a, _b;
119396
119477
  var path = toPath(fileName);
119397
119478
  if (useSourceOfProjectReferenceRedirect) {
119398
119479
  var source = getSourceOfProjectReferenceRedirect(path);
@@ -119479,7 +119560,8 @@ var ts;
119479
119560
  }
119480
119561
  }
119481
119562
  // We haven't looked for this file, do so now and cache result
119482
- 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);
119563
+ var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
119564
+ 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));
119483
119565
  if (packageId) {
119484
119566
  var packageIdKey = ts.packageIdToString(packageId);
119485
119567
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -119507,6 +119589,9 @@ var ts;
119507
119589
  file.path = path;
119508
119590
  file.resolvedPath = toPath(fileName);
119509
119591
  file.originalFileName = originalFileName;
119592
+ file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
119593
+ file.packageJsonScope = sourceFileOptions.packageJsonScope;
119594
+ // TODO: handle watch when same file has changes in failed and affecting locations
119510
119595
  addFileIncludeReason(file, reason);
119511
119596
  if (host.useCaseSensitiveFileNames()) {
119512
119597
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -120137,7 +120222,7 @@ var ts;
120137
120222
  fileIncludeReasons = undefined;
120138
120223
  var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
120139
120224
  var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
120140
- var redirectInfo = file && ts.explainIfFileIsRedirect(file);
120225
+ var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file);
120141
120226
  var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
120142
120227
  return location && isReferenceFileLocation(location) ?
120143
120228
  ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
@@ -122442,7 +122527,7 @@ var ts;
122442
122527
  * "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot"
122443
122528
  * @param dirPath
122444
122529
  */
122445
- function canWatchDirectory(dirPath) {
122530
+ function canWatchDirectoryOrFile(dirPath) {
122446
122531
  var rootLength = ts.getRootLength(dirPath);
122447
122532
  if (dirPath.length === rootLength) {
122448
122533
  // Ignore "/", "c:/"
@@ -122479,7 +122564,7 @@ var ts;
122479
122564
  }
122480
122565
  return true;
122481
122566
  }
122482
- ts.canWatchDirectory = canWatchDirectory;
122567
+ ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
122483
122568
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
122484
122569
  var filesWithChangedSetOfUnresolvedImports;
122485
122570
  var filesWithInvalidatedResolutions;
@@ -122488,7 +122573,9 @@ var ts;
122488
122573
  var resolutionsWithFailedLookups = [];
122489
122574
  var resolutionsWithOnlyAffectingLocations = [];
122490
122575
  var resolvedFileToResolution = ts.createMultiMap();
122576
+ var impliedFormatPackageJsons = new ts.Map();
122491
122577
  var hasChangedAutomaticTypeDirectiveNames = false;
122578
+ var affectingPathChecksForFile;
122492
122579
  var affectingPathChecks;
122493
122580
  var failedLookupChecks;
122494
122581
  var startsWithPathChecks;
@@ -122528,7 +122615,7 @@ var ts;
122528
122615
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
122529
122616
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122530
122617
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122531
- startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
122618
+ startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
122532
122619
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
122533
122620
  resolveModuleNames: resolveModuleNames,
122534
122621
  getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
@@ -122566,15 +122653,19 @@ var ts;
122566
122653
  resolvedModuleNames.clear();
122567
122654
  resolvedTypeReferenceDirectives.clear();
122568
122655
  resolvedFileToResolution.clear();
122656
+ nonRelativeExternalModuleResolutions.clear();
122569
122657
  resolutionsWithFailedLookups.length = 0;
122570
122658
  resolutionsWithOnlyAffectingLocations.length = 0;
122571
122659
  failedLookupChecks = undefined;
122572
122660
  startsWithPathChecks = undefined;
122573
122661
  isInDirectoryChecks = undefined;
122574
122662
  affectingPathChecks = undefined;
122663
+ affectingPathChecksForFile = undefined;
122575
122664
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122576
122665
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122577
- clearPerDirectoryResolutions();
122666
+ moduleResolutionCache.clear();
122667
+ typeReferenceDirectiveResolutionCache.clear();
122668
+ impliedFormatPackageJsons.clear();
122578
122669
  hasChangedAutomaticTypeDirectiveNames = false;
122579
122670
  }
122580
122671
  function startRecordingFilesWithChangedResolutions() {
@@ -122606,15 +122697,40 @@ var ts;
122606
122697
  return function (path) { return (!!collected && collected.has(path)) ||
122607
122698
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
122608
122699
  }
122609
- function clearPerDirectoryResolutions() {
122610
- moduleResolutionCache.clear();
122611
- typeReferenceDirectiveResolutionCache.clear();
122612
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122613
- nonRelativeExternalModuleResolutions.clear();
122700
+ function startCachingPerDirectoryResolution() {
122701
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
122702
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
122614
122703
  }
122615
- function finishCachingPerDirectoryResolution() {
122704
+ function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
122616
122705
  filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
122617
- clearPerDirectoryResolutions();
122706
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122707
+ nonRelativeExternalModuleResolutions.clear();
122708
+ // Update file watches
122709
+ if (newProgram !== oldProgram) {
122710
+ newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
122711
+ var _a, _b, _c;
122712
+ var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
122713
+ var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
122714
+ for (var i = existing.length; i < expected; i++) {
122715
+ createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false);
122716
+ }
122717
+ if (existing.length > expected) {
122718
+ for (var i = expected; i < existing.length; i++) {
122719
+ fileWatchesOfAffectingLocations.get(existing[i]).files--;
122720
+ }
122721
+ }
122722
+ if (expected)
122723
+ impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
122724
+ else
122725
+ impliedFormatPackageJsons.delete(newFile.path);
122726
+ });
122727
+ impliedFormatPackageJsons.forEach(function (existing, path) {
122728
+ if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
122729
+ existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
122730
+ impliedFormatPackageJsons.delete(path);
122731
+ }
122732
+ });
122733
+ }
122618
122734
  directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
122619
122735
  if (watcher.refCount === 0) {
122620
122736
  directoryWatchesOfFailedLookups.delete(path);
@@ -122622,7 +122738,7 @@ var ts;
122622
122738
  }
122623
122739
  });
122624
122740
  fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
122625
- if (watcher.refCount === 0) {
122741
+ if (watcher.files === 0 && watcher.resolutions === 0) {
122626
122742
  fileWatchesOfAffectingLocations.delete(path);
122627
122743
  watcher.watcher.close();
122628
122744
  // Ensure when watching symlinked package.json, we can close the actual file watcher only once
@@ -122853,7 +122969,7 @@ var ts;
122853
122969
  }
122854
122970
  // If the directory is node_modules use it to watch, always watch it recursively
122855
122971
  if (ts.isNodeModulesDirectory(dirPath)) {
122856
- return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
122972
+ return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
122857
122973
  }
122858
122974
  var nonRecursive = true;
122859
122975
  // Use some ancestor of the root directory
@@ -122871,7 +122987,7 @@ var ts;
122871
122987
  dir = ts.getDirectoryPath(dir);
122872
122988
  }
122873
122989
  }
122874
- return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
122990
+ return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
122875
122991
  }
122876
122992
  function isPathWithDefaultFailedLookupExtension(path) {
122877
122993
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
@@ -122942,46 +123058,58 @@ var ts;
122942
123058
  // Watch package json
122943
123059
  for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
122944
123060
  var affectingLocation = affectingLocations_1[_i];
122945
- createFileWatcherOfAffectingLocation(affectingLocation);
123061
+ createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
122946
123062
  }
122947
123063
  }
122948
- function createFileWatcherOfAffectingLocation(affectingLocation) {
122949
- var path = resolutionHost.toPath(affectingLocation);
122950
- var fileWatcher = fileWatchesOfAffectingLocations.get(path);
123064
+ function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
123065
+ var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
122951
123066
  if (fileWatcher) {
122952
- fileWatcher.refCount++;
123067
+ if (forResolution)
123068
+ fileWatcher.resolutions++;
123069
+ else
123070
+ fileWatcher.files++;
122953
123071
  return;
122954
123072
  }
122955
123073
  var locationToWatch = affectingLocation;
122956
- var locationToWatchPath = path;
122957
123074
  if (resolutionHost.realpath) {
122958
123075
  locationToWatch = resolutionHost.realpath(affectingLocation);
122959
- locationToWatchPath = resolutionHost.toPath(locationToWatch);
122960
- if (path !== locationToWatchPath) {
122961
- var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
123076
+ if (affectingLocation !== locationToWatch) {
123077
+ var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch);
122962
123078
  if (fileWatcher_1) {
122963
- fileWatcher_1.refCount++;
122964
- fileWatcher_1.paths.add(path);
122965
- fileWatchesOfAffectingLocations.set(path, fileWatcher_1);
123079
+ if (forResolution)
123080
+ fileWatcher_1.resolutions++;
123081
+ else
123082
+ fileWatcher_1.files++;
123083
+ fileWatcher_1.paths.add(affectingLocation);
123084
+ fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1);
122966
123085
  return;
122967
123086
  }
122968
123087
  }
122969
123088
  }
122970
123089
  var paths = new ts.Set();
122971
- paths.add(locationToWatchPath);
123090
+ paths.add(locationToWatch);
122972
123091
  var watcher = {
122973
- watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
122974
- cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
122975
- paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); });
122976
- resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122977
- }),
122978
- refCount: 1,
123092
+ watcher: canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
123093
+ resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
123094
+ cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
123095
+ paths.forEach(function (path) {
123096
+ var _a;
123097
+ if (watcher.resolutions)
123098
+ (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
123099
+ if (watcher.files)
123100
+ (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
123101
+ (_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
123102
+ });
123103
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123104
+ }) : ts.noopFileWatcher,
123105
+ resolutions: forResolution ? 1 : 0,
123106
+ files: forResolution ? 0 : 1,
122979
123107
  paths: paths,
122980
123108
  };
122981
- fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher);
122982
- if (path !== locationToWatchPath) {
122983
- fileWatchesOfAffectingLocations.set(path, watcher);
122984
- paths.add(path);
123109
+ fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
123110
+ if (affectingLocation !== locationToWatch) {
123111
+ fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
123112
+ paths.add(affectingLocation);
122985
123113
  }
122986
123114
  }
122987
123115
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
@@ -123049,8 +123177,8 @@ var ts;
123049
123177
  }
123050
123178
  for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
123051
123179
  var affectingLocation = affectingLocations_2[_a];
123052
- var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
123053
- watcher.refCount--;
123180
+ var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
123181
+ watcher.resolutions--;
123054
123182
  }
123055
123183
  }
123056
123184
  function removeDirectoryWatcher(dirPath) {
@@ -123104,7 +123232,7 @@ var ts;
123104
123232
  resolution.isInvalidated = invalidated = true;
123105
123233
  for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
123106
123234
  var containingFilePath = _b[_a];
123107
- (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
123235
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
123108
123236
  // When its a file with inferred types resolution, invalidate type reference directive resolution
123109
123237
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
123110
123238
  }
@@ -123171,10 +123299,25 @@ var ts;
123171
123299
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
123172
123300
  }
123173
123301
  function invalidateResolutionsOfFailedLookupLocations() {
123302
+ var _a;
123303
+ var invalidated = false;
123304
+ if (affectingPathChecksForFile) {
123305
+ (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
123306
+ if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
123307
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
123308
+ invalidated = true;
123309
+ }
123310
+ });
123311
+ affectingPathChecksForFile = undefined;
123312
+ }
123174
123313
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
123175
- return false;
123314
+ return invalidated;
123315
+ }
123316
+ invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
123317
+ var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
123318
+ if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
123319
+ packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; });
123176
123320
  }
123177
- var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
123178
123321
  failedLookupChecks = undefined;
123179
123322
  startsWithPathChecks = undefined;
123180
123323
  isInDirectoryChecks = undefined;
@@ -123187,17 +123330,15 @@ var ts;
123187
123330
  return true;
123188
123331
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
123189
123332
  return false;
123190
- return resolution.failedLookupLocations.some(function (location) {
123191
- var locationPath = resolutionHost.toPath(location);
123192
- return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
123193
- ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
123194
- ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
123195
- });
123333
+ return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); });
123334
+ }
123335
+ function isInvalidatedFailedLookup(locationPath) {
123336
+ return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
123337
+ ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
123338
+ ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
123196
123339
  }
123197
123340
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
123198
- return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
123199
- return affectingPathChecks.has(resolutionHost.toPath(location));
123200
- });
123341
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
123201
123342
  }
123202
123343
  function closeTypeRootsWatch() {
123203
123344
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -123263,7 +123404,7 @@ var ts;
123263
123404
  function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
123264
123405
  var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
123265
123406
  var dirPath = resolutionHost.toPath(dir);
123266
- return dirPath === rootPath || canWatchDirectory(dirPath);
123407
+ return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
123267
123408
  }
123268
123409
  }
123269
123410
  ts.createResolutionCache = createResolutionCache;
@@ -124236,23 +124377,46 @@ var ts;
124236
124377
  var file = _c[_i];
124237
124378
  write("" + toFileName(file, relativeFileName));
124238
124379
  (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
124239
- (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
124380
+ (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
124240
124381
  }
124241
124382
  }
124242
124383
  ts.explainFiles = explainFiles;
124243
- function explainIfFileIsRedirect(file, fileNameConvertor) {
124384
+ function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
124385
+ var _a;
124244
124386
  var result;
124245
124387
  if (file.path !== file.resolvedPath) {
124246
- (result || (result = [])).push(ts.chainDiagnosticMessages(
124388
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124247
124389
  /*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
124248
124390
  }
124249
124391
  if (file.redirectInfo) {
124250
- (result || (result = [])).push(ts.chainDiagnosticMessages(
124392
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124251
124393
  /*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
124252
124394
  }
124395
+ if (ts.isExternalOrCommonJsModule(file)) {
124396
+ switch (file.impliedNodeFormat) {
124397
+ case ts.ModuleKind.ESNext:
124398
+ if (file.packageJsonScope) {
124399
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124400
+ /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
124401
+ }
124402
+ break;
124403
+ case ts.ModuleKind.CommonJS:
124404
+ if (file.packageJsonScope) {
124405
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124406
+ /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
124407
+ ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
124408
+ ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
124409
+ }
124410
+ else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
124411
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124412
+ /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
124413
+ }
124414
+ break;
124415
+ }
124416
+ }
124253
124417
  return result;
124254
124418
  }
124255
- ts.explainIfFileIsRedirect = explainIfFileIsRedirect;
124419
+ ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat;
124256
124420
  function getMatchedFileSpec(program, fileName) {
124257
124421
  var _a;
124258
124422
  var configFile = program.getCompilerOptions().configFile;
@@ -124462,6 +124626,7 @@ var ts;
124462
124626
  MissingFile: "Missing file",
124463
124627
  WildcardDirectory: "Wild card directory",
124464
124628
  FailedLookupLocations: "Failed Lookup Locations",
124629
+ AffectingFileLocation: "File location affecting resolution",
124465
124630
  TypeRoots: "Type roots",
124466
124631
  ConfigFileOfReferencedProject: "Config file of referened project",
124467
124632
  ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
@@ -124785,7 +124950,7 @@ var ts;
124785
124950
  compilerHost.getCompilationSettings = function () { return compilerOptions; };
124786
124951
  compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
124787
124952
  compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
124788
- compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); };
124953
+ compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); };
124789
124954
  compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
124790
124955
  compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
124791
124956
  compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
@@ -124819,6 +124984,9 @@ var ts;
124819
124984
  return host.resolveTypeReferenceDirectives.apply(host, args);
124820
124985
  }) :
124821
124986
  (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
124987
+ compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
124988
+ ts.maybeBind(host, host.getModuleResolutionCache) :
124989
+ (function () { return resolutionCache.getModuleResolutionCache(); });
124822
124990
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
124823
124991
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
124824
124992
  synchronizeProgram();
@@ -124921,8 +125089,9 @@ var ts;
124921
125089
  resolutionCache.startCachingPerDirectoryResolution();
124922
125090
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
124923
125091
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
125092
+ var oldProgram = getCurrentProgram();
124924
125093
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
124925
- resolutionCache.finishCachingPerDirectoryResolution();
125094
+ resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
124926
125095
  // Update watches
124927
125096
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
124928
125097
  if (needsUpdateInTypeRootWatch) {
@@ -125004,9 +125173,6 @@ var ts;
125004
125173
  sourceFilesCache.set(path, false);
125005
125174
  }
125006
125175
  }
125007
- if (sourceFile) {
125008
- sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
125009
- }
125010
125176
  return sourceFile;
125011
125177
  }
125012
125178
  return hostSourceFile.sourceFile;
@@ -125522,6 +125688,7 @@ var ts;
125522
125688
  compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
125523
125689
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
125524
125690
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
125691
+ compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
125525
125692
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
125526
125693
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
125527
125694
  if (!compilerHost.resolveModuleNames) {
@@ -137321,60 +137488,64 @@ var ts;
137321
137488
  }
137322
137489
  return settingsOrHost;
137323
137490
  }
137324
- function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
137491
+ function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
137325
137492
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
137326
137493
  var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
137327
- return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
137494
+ return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
137328
137495
  }
137329
- function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
137330
- return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
137496
+ function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
137497
+ return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions);
137331
137498
  }
137332
- function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
137499
+ function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
137333
137500
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
137334
137501
  var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
137335
- return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
137502
+ return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
137336
137503
  }
137337
- function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
137338
- return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
137504
+ function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
137505
+ return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions);
137339
137506
  }
137340
137507
  function getDocumentRegistryEntry(bucketEntry, scriptKind) {
137341
137508
  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"));
137342
137509
  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);
137343
137510
  return entry;
137344
137511
  }
137345
- function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
137512
+ function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) {
137346
137513
  var _a, _b, _c, _d;
137347
137514
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
137348
137515
  var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
137349
137516
  var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
137350
137517
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
137351
- var sourceFileOptions = {
137352
- languageVersion: scriptTarget,
137353
- 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),
137354
- setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
137355
- };
137518
+ var sourceFileOptions = typeof languageVersionOrOptions === "object" ?
137519
+ languageVersionOrOptions :
137520
+ {
137521
+ languageVersion: scriptTarget,
137522
+ 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),
137523
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
137524
+ };
137525
+ sourceFileOptions.languageVersion = scriptTarget;
137356
137526
  var oldBucketCount = buckets.size;
137357
- var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
137527
+ var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat);
137528
+ var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); });
137358
137529
  if (ts.tracing) {
137359
137530
  if (buckets.size > oldBucketCount) {
137360
137531
  // It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
137361
137532
  // perhaps they are for two projects that don't have any overlap.
137362
137533
  // Bonus: these events can help us interpret the more interesting event below.
137363
- ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
137534
+ ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode });
137364
137535
  }
137365
137536
  // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
137366
137537
  // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
137367
137538
  // Skip .d.ts files to reduce noise (should also cover most of node_modules).
137368
137539
  var otherBucketKey = !ts.isDeclarationFileName(path) &&
137369
- ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
137540
+ ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; });
137370
137541
  if (otherBucketKey) {
137371
- ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
137542
+ ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode });
137372
137543
  }
137373
137544
  }
137374
137545
  var bucketEntry = bucket.get(path);
137375
137546
  var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
137376
137547
  if (!entry && externalCache) {
137377
- var sourceFile = externalCache.getDocument(key, path);
137548
+ var sourceFile = externalCache.getDocument(keyWithMode, path);
137378
137549
  if (sourceFile) {
137379
137550
  ts.Debug.assert(acquiring);
137380
137551
  entry = {
@@ -137388,7 +137559,7 @@ var ts;
137388
137559
  // Have never seen this file with these settings. Create a new source file for it.
137389
137560
  var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
137390
137561
  if (externalCache) {
137391
- externalCache.setDocument(key, path, sourceFile);
137562
+ externalCache.setDocument(keyWithMode, path, sourceFile);
137392
137563
  }
137393
137564
  entry = {
137394
137565
  sourceFile: sourceFile,
@@ -137403,7 +137574,7 @@ var ts;
137403
137574
  if (entry.sourceFile.version !== version) {
137404
137575
  entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217
137405
137576
  if (externalCache) {
137406
- externalCache.setDocument(key, path, entry.sourceFile);
137577
+ externalCache.setDocument(keyWithMode, path, entry.sourceFile);
137407
137578
  }
137408
137579
  }
137409
137580
  // If we're acquiring, then this is the first time this LS is asking for this document.
@@ -137432,13 +137603,13 @@ var ts;
137432
137603
  }
137433
137604
  }
137434
137605
  }
137435
- function releaseDocument(fileName, compilationSettings, scriptKind) {
137606
+ function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) {
137436
137607
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
137437
137608
  var key = getKeyForCompilationSettings(compilationSettings);
137438
- return releaseDocumentWithKey(path, key, scriptKind);
137609
+ return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat);
137439
137610
  }
137440
- function releaseDocumentWithKey(path, key, scriptKind) {
137441
- var bucket = ts.Debug.checkDefined(buckets.get(key));
137611
+ function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) {
137612
+ var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat)));
137442
137613
  var bucketEntry = bucket.get(path);
137443
137614
  var entry = getDocumentRegistryEntry(bucketEntry, scriptKind);
137444
137615
  entry.languageServiceRefCount--;
@@ -137495,6 +137666,9 @@ var ts;
137495
137666
  function getKeyForCompilationSettings(settings) {
137496
137667
  return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined);
137497
137668
  }
137669
+ function getDocumentRegistryBucketKeyWithMode(key, mode) {
137670
+ return (mode ? key + "|" + mode : key);
137671
+ }
137498
137672
  })(ts || (ts = {}));
137499
137673
  /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */
137500
137674
  /* @internal */
@@ -166738,12 +166912,12 @@ var ts;
166738
166912
  // not part of the new program.
166739
166913
  function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
166740
166914
  var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
166741
- documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind);
166915
+ documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
166742
166916
  }
166743
- function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) {
166744
- return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile);
166917
+ function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
166918
+ return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
166745
166919
  }
166746
- function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) {
166920
+ function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) {
166747
166921
  ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
166748
166922
  // The program is asking for this file, check first if the host can locate it.
166749
166923
  // If the host can not locate the file, then it does not exist. return undefined
@@ -166786,17 +166960,17 @@ var ts;
166786
166960
  // file's script kind, i.e. in one project some file is treated as ".ts"
166787
166961
  // and in another as ".js"
166788
166962
  if (scriptKind === oldSourceFile.scriptKind) {
166789
- return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
166963
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
166790
166964
  }
166791
166965
  else {
166792
166966
  // Release old source file and fall through to aquire new file with new script kind
166793
- documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind);
166967
+ documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
166794
166968
  }
166795
166969
  }
166796
166970
  // We didn't already have the file. Fall through and acquire it from the registry.
166797
166971
  }
166798
166972
  // Could not find this file in the old program, create a new SourceFile for it.
166799
- return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
166973
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
166800
166974
  }
166801
166975
  }
166802
166976
  // TODO: GH#18217 frequently asserted as defined
@@ -166875,7 +167049,7 @@ var ts;
166875
167049
  // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
166876
167050
  var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
166877
167051
  ts.forEach(program.getSourceFiles(), function (f) {
166878
- return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind);
167052
+ return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat);
166879
167053
  });
166880
167054
  program = undefined; // TODO: GH#18217
166881
167055
  }
@@ -167792,6 +167966,7 @@ var ts;
167792
167966
  getEmitOutput: getEmitOutput,
167793
167967
  getNonBoundSourceFile: getNonBoundSourceFile,
167794
167968
  getProgram: getProgram,
167969
+ getCurrentProgram: function () { return program; },
167795
167970
  getAutoImportProvider: getAutoImportProvider,
167796
167971
  updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
167797
167972
  getApplicableRefactors: getApplicableRefactors,
@@ -171428,7 +171603,7 @@ var ts;
171428
171603
  };
171429
171604
  /*@internal*/
171430
171605
  Project.prototype.watchAffectingFileLocation = function (file, cb) {
171431
- return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.PackageJson, this);
171606
+ return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.AffectingFileLocation, this);
171432
171607
  };
171433
171608
  /*@internal*/
171434
171609
  Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () {
@@ -171965,7 +172140,7 @@ var ts;
171965
172140
  };
171966
172141
  Project.prototype.updateGraphWorker = function () {
171967
172142
  var _this = this;
171968
- var oldProgram = this.program;
172143
+ var oldProgram = this.languageService.getCurrentProgram();
171969
172144
  ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
171970
172145
  this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName());
171971
172146
  var start = ts.timestamp();
@@ -171974,7 +172149,7 @@ var ts;
171974
172149
  this.program = this.languageService.getProgram(); // TODO: GH#18217
171975
172150
  this.dirty = false;
171976
172151
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
171977
- this.resolutionCache.finishCachingPerDirectoryResolution();
172152
+ this.resolutionCache.finishCachingPerDirectoryResolution(this.program, oldProgram);
171978
172153
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
171979
172154
  ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
171980
172155
  // bump up the version if
@@ -174432,7 +174607,7 @@ var ts;
174432
174607
  // created when any of the script infos are added as root of inferred project
174433
174608
  if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) {
174434
174609
  // If we cannot watch config file existence without configured project, close the configured file watcher
174435
- if (!ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath))) {
174610
+ if (!ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath))) {
174436
174611
  configFileExistenceInfo.watcher.close();
174437
174612
  configFileExistenceInfo.watcher = noopConfigFileWatcher;
174438
174613
  }
@@ -174512,7 +174687,7 @@ var ts;
174512
174687
  // Set this file as the root of inferred project
174513
174688
  (configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = new ts.Map())).set(info.path, true);
174514
174689
  // If there is no configured project for this config file, add the file watcher
174515
- configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath)) ?
174690
+ configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath)) ?
174516
174691
  _this.watchFactory.watchFile(configFileName, function (_filename, eventKind) { return _this.onConfigFileChanged(canonicalConfigFilePath, eventKind); }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ConfigFileForInferredRoot) :
174517
174692
  noopConfigFileWatcher);
174518
174693
  });