typescript 4.6.0-dev.20220117 → 4.6.0-dev.20220121

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
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220117";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220121";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -6810,11 +6810,15 @@ var ts;
6810
6810
  ts.getFileWatcherEventKind = getFileWatcherEventKind;
6811
6811
  /*@internal*/
6812
6812
  ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
6813
+ var curSysLog = ts.noop; // eslint-disable-line prefer-const
6813
6814
  /*@internal*/
6814
- ts.sysLog = ts.noop; // eslint-disable-line prefer-const
6815
+ function sysLog(s) {
6816
+ return curSysLog(s);
6817
+ }
6818
+ ts.sysLog = sysLog;
6815
6819
  /*@internal*/
6816
6820
  function setSysLog(logger) {
6817
- ts.sysLog = logger;
6821
+ curSysLog = logger;
6818
6822
  }
6819
6823
  ts.setSysLog = setSysLog;
6820
6824
  /**
@@ -6949,7 +6953,7 @@ var ts;
6949
6953
  }
6950
6954
  function onTimerToUpdateChildWatches() {
6951
6955
  timerToUpdateChildWatches = undefined;
6952
- ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
6956
+ sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
6953
6957
  var start = ts.timestamp();
6954
6958
  var invokeMap = new ts.Map();
6955
6959
  while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
@@ -6962,7 +6966,7 @@ var ts;
6962
6966
  var hasChanges = updateChildWatches(dirName, dirPath, options);
6963
6967
  invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
6964
6968
  }
6965
- ts.sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
6969
+ sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
6966
6970
  callbackCache.forEach(function (callbacks, rootDirName) {
6967
6971
  var existing = invokeMap.get(rootDirName);
6968
6972
  if (existing) {
@@ -6978,7 +6982,7 @@ var ts;
6978
6982
  }
6979
6983
  });
6980
6984
  var elapsed = ts.timestamp() - start;
6981
- ts.sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
6985
+ sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
6982
6986
  }
6983
6987
  function removeChildWatches(parentWatcher) {
6984
6988
  if (!parentWatcher)
@@ -7565,7 +7569,7 @@ var ts;
7565
7569
  * @param createWatcher
7566
7570
  */
7567
7571
  function invokeCallbackAndUpdateWatcher(createWatcher) {
7568
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7572
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7569
7573
  // Call the callback for current directory
7570
7574
  callback("rename", "");
7571
7575
  // If watcher is not closed, update it
@@ -7590,7 +7594,7 @@ var ts;
7590
7594
  }
7591
7595
  }
7592
7596
  if (hitSystemWatcherLimit) {
7593
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7597
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7594
7598
  return watchPresentFileSystemEntryWithFsWatchFile();
7595
7599
  }
7596
7600
  try {
@@ -7606,7 +7610,7 @@ var ts;
7606
7610
  // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
7607
7611
  // so instead of throwing error, use fs.watchFile
7608
7612
  hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7609
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7613
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7610
7614
  return watchPresentFileSystemEntryWithFsWatchFile();
7611
7615
  }
7612
7616
  }
@@ -8205,6 +8209,7 @@ var ts;
8205
8209
  Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
8206
8210
  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."),
8207
8211
  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."),
8212
+ catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8208
8213
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
8209
8214
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
8210
8215
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
@@ -8692,6 +8697,7 @@ var ts;
8692
8697
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."),
8693
8698
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
8694
8699
  Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
8700
+ Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
8695
8701
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8696
8702
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8697
8703
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -9085,7 +9091,7 @@ var ts;
9085
9091
  Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
9086
9092
  _0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, ts.DiagnosticCategory.Error, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"),
9087
9093
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
9088
- Found_0_errors_in_1_file: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_file_6260", "Found {0} errors in 1 file."),
9094
+ Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
9089
9095
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
9090
9096
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
9091
9097
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
@@ -15858,7 +15864,7 @@ var ts;
15858
15864
  }
15859
15865
  ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
15860
15866
  function getExternalModuleRequireArgument(node) {
15861
- return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
15867
+ return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
15862
15868
  }
15863
15869
  ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
15864
15870
  function isInternalModuleImportEqualsDeclaration(node) {
@@ -15916,17 +15922,29 @@ var ts;
15916
15922
  * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`).
15917
15923
  * This function does not test if the node is in a JavaScript file or not.
15918
15924
  */
15919
- function isRequireVariableDeclaration(node) {
15925
+ function isVariableDeclarationInitializedToRequire(node) {
15926
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false);
15927
+ }
15928
+ ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
15929
+ /**
15930
+ * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`.
15931
+ */
15932
+ function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
15933
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true);
15934
+ }
15935
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
15936
+ function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
15920
15937
  if (node.kind === 202 /* BindingElement */) {
15921
15938
  node = node.parent.parent;
15922
15939
  }
15923
- return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true);
15940
+ return ts.isVariableDeclaration(node) &&
15941
+ !!node.initializer &&
15942
+ isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
15924
15943
  }
15925
- ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
15926
15944
  function isRequireVariableStatement(node) {
15927
15945
  return ts.isVariableStatement(node)
15928
15946
  && node.declarationList.declarations.length > 0
15929
- && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); });
15947
+ && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
15930
15948
  }
15931
15949
  ts.isRequireVariableStatement = isRequireVariableStatement;
15932
15950
  function isSingleOrDoubleQuote(charCode) {
@@ -19413,7 +19431,7 @@ var ts;
19413
19431
  getSourceMapSourceConstructor: function () { return SourceMapSource; },
19414
19432
  };
19415
19433
  function setObjectAllocator(alloc) {
19416
- ts.objectAllocator = alloc;
19434
+ Object.assign(ts.objectAllocator, alloc);
19417
19435
  }
19418
19436
  ts.setObjectAllocator = setObjectAllocator;
19419
19437
  function formatStringFromArgs(text, args, baseIndex) {
@@ -19421,13 +19439,22 @@ var ts;
19421
19439
  return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
19422
19440
  }
19423
19441
  ts.formatStringFromArgs = formatStringFromArgs;
19442
+ var localizedDiagnosticMessages;
19424
19443
  /* @internal */
19425
19444
  function setLocalizedDiagnosticMessages(messages) {
19426
- ts.localizedDiagnosticMessages = messages;
19445
+ localizedDiagnosticMessages = messages;
19427
19446
  }
19428
19447
  ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
19448
+ /* @internal */
19449
+ // If the localized messages json is unset, and if given function use it to set the json
19450
+ function maybeSetLocalizedDiagnosticMessages(getMessages) {
19451
+ if (!localizedDiagnosticMessages && getMessages) {
19452
+ localizedDiagnosticMessages = getMessages();
19453
+ }
19454
+ }
19455
+ ts.maybeSetLocalizedDiagnosticMessages = maybeSetLocalizedDiagnosticMessages;
19429
19456
  function getLocaleSpecificMessage(message) {
19430
- return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
19457
+ return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
19431
19458
  }
19432
19459
  ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
19433
19460
  function createDetachedDiagnostic(fileName, start, length, message) {
@@ -35036,7 +35063,7 @@ var ts;
35036
35063
  // one out no matter what.
35037
35064
  var finallyBlock;
35038
35065
  if (!catchClause || token() === 96 /* FinallyKeyword */) {
35039
- parseExpected(96 /* FinallyKeyword */);
35066
+ parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
35040
35067
  finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
35041
35068
  }
35042
35069
  return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
@@ -36080,7 +36107,7 @@ var ts;
36080
36107
  var pos = getNodePos();
36081
36108
  var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
36082
36109
  parseExpected(58 /* ColonToken */);
36083
- var value = parseLiteralLikeNode(10 /* StringLiteral */);
36110
+ var value = parseAssignmentExpressionOrHigher();
36084
36111
  return finishNode(factory.createAssertEntry(name, value), pos);
36085
36112
  }
36086
36113
  function parseAssertClause() {
@@ -44497,7 +44524,7 @@ var ts;
44497
44524
  maybeBindExpressionFlowIfCall(node.expression);
44498
44525
  }
44499
44526
  function maybeBindExpressionFlowIfCall(node) {
44500
- // A top level or LHS of comma expression call expression with a dotted function name and at least one argument
44527
+ // A top level or comma expression call expression with a dotted function name and at least one argument
44501
44528
  // is potentially an assertion and is therefore included in the control flow.
44502
44529
  if (node.kind === 207 /* CallExpression */) {
44503
44530
  var call = node;
@@ -44665,22 +44692,27 @@ var ts;
44665
44692
  }
44666
44693
  return state;
44667
44694
  }
44668
- function onLeft(left, state, _node) {
44695
+ function onLeft(left, state, node) {
44669
44696
  if (!state.skip) {
44670
- return maybeBind(left);
44697
+ var maybeBound = maybeBind(left);
44698
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44699
+ maybeBindExpressionFlowIfCall(left);
44700
+ }
44701
+ return maybeBound;
44671
44702
  }
44672
44703
  }
44673
- function onOperator(operatorToken, state, node) {
44704
+ function onOperator(operatorToken, state, _node) {
44674
44705
  if (!state.skip) {
44675
- if (operatorToken.kind === 27 /* CommaToken */) {
44676
- maybeBindExpressionFlowIfCall(node.left);
44677
- }
44678
44706
  bind(operatorToken);
44679
44707
  }
44680
44708
  }
44681
- function onRight(right, state, _node) {
44709
+ function onRight(right, state, node) {
44682
44710
  if (!state.skip) {
44683
- return maybeBind(right);
44711
+ var maybeBound = maybeBind(right);
44712
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44713
+ maybeBindExpressionFlowIfCall(right);
44714
+ }
44715
+ return maybeBound;
44684
44716
  }
44685
44717
  }
44686
44718
  function onExit(node, state) {
@@ -45423,6 +45455,8 @@ var ts;
45423
45455
  return;
45424
45456
  }
45425
45457
  ts.setParent(node, parent);
45458
+ if (ts.tracing)
45459
+ node.tracingPath = file.path;
45426
45460
  var saveInStrictMode = inStrictMode;
45427
45461
  // Even though in the AST the jsdoc @typedef node belongs to the current node,
45428
45462
  // its symbol might be in the same scope with the current node's symbol. Consider:
@@ -46243,7 +46277,7 @@ var ts;
46243
46277
  checkStrictModeEvalOrArguments(node, node.name);
46244
46278
  }
46245
46279
  if (!ts.isBindingPattern(node.name)) {
46246
- if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) {
46280
+ if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
46247
46281
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
46248
46282
  }
46249
46283
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -49026,7 +49060,7 @@ var ts;
49026
49060
  && isAliasableOrJsExpression(node.parent.right)
49027
49061
  || node.kind === 295 /* ShorthandPropertyAssignment */
49028
49062
  || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
49029
- || ts.isRequireVariableDeclaration(node);
49063
+ || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
49030
49064
  }
49031
49065
  function isAliasableOrJsExpression(e) {
49032
49066
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -49814,8 +49848,14 @@ var ts;
49814
49848
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49815
49849
  var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
49816
49850
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49817
- var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
49851
+ var sourceFile = resolvedModule
49852
+ && (!resolutionDiagnostic || resolutionDiagnostic === ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set)
49853
+ && host.getSourceFile(resolvedModule.resolvedFileName);
49818
49854
  if (sourceFile) {
49855
+ // If there's a resolutionDiagnostic we need to report it even if a sourceFile is found.
49856
+ if (resolutionDiagnostic) {
49857
+ error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
49858
+ }
49819
49859
  if (sourceFile.symbol) {
49820
49860
  if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
49821
49861
  errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
@@ -50957,6 +50997,7 @@ var ts;
50957
50997
  getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
50958
50998
  getCurrentDirectory: function () { return host.getCurrentDirectory(); },
50959
50999
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
51000
+ getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
50960
51001
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
50961
51002
  redirectTargetsMap: host.redirectTargetsMap,
50962
51003
  getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
@@ -77903,7 +77944,7 @@ var ts;
77903
77944
  }
77904
77945
  }
77905
77946
  function checkExpression(node, checkMode, forceTuple) {
77906
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
77947
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
77907
77948
  var saveCurrentNode = currentNode;
77908
77949
  currentNode = node;
77909
77950
  instantiationCount = 0;
@@ -80584,7 +80625,7 @@ var ts;
80584
80625
  }
80585
80626
  // For a commonjs `const x = require`, validate the alias and exit
80586
80627
  var symbol = getSymbolOfNode(node);
80587
- if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) {
80628
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
80588
80629
  checkAliasSymbol(node);
80589
80630
  return;
80590
80631
  }
@@ -80662,7 +80703,7 @@ var ts;
80662
80703
  return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
80663
80704
  }
80664
80705
  function checkVariableDeclaration(node) {
80665
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
80706
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
80666
80707
  checkGrammarVariableDeclaration(node);
80667
80708
  checkVariableLikeDeclaration(node);
80668
80709
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -83052,6 +83093,17 @@ var ts;
83052
83093
  return false;
83053
83094
  }
83054
83095
  }
83096
+ if (!ts.isImportEqualsDeclaration(node) && node.assertClause) {
83097
+ var hasError = false;
83098
+ for (var _i = 0, _a = node.assertClause.elements; _i < _a.length; _i++) {
83099
+ var clause = _a[_i];
83100
+ if (!ts.isStringLiteral(clause.value)) {
83101
+ hasError = true;
83102
+ error(clause.value, ts.Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
83103
+ }
83104
+ }
83105
+ return !hasError;
83106
+ }
83055
83107
  return true;
83056
83108
  }
83057
83109
  function checkAliasSymbol(node) {
@@ -83745,7 +83797,7 @@ var ts;
83745
83797
  }
83746
83798
  }
83747
83799
  function checkDeferredNode(node) {
83748
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
83800
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
83749
83801
  var saveCurrentNode = currentNode;
83750
83802
  currentNode = node;
83751
83803
  instantiationCount = 0;
@@ -87679,7 +87731,7 @@ var ts;
87679
87731
  return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine);
87680
87732
  case 293 /* AssertEntry */:
87681
87733
  ts.Debug.type(node);
87682
- return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isStringLiteral));
87734
+ return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode));
87683
87735
  case 266 /* ImportClause */:
87684
87736
  ts.Debug.type(node);
87685
87737
  return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
@@ -95529,10 +95581,19 @@ var ts;
95529
95581
  var _a;
95530
95582
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95531
95583
  var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95532
- var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95584
+ var args = [tagName, objectProperties];
95585
+ // function jsx(type, config, maybeKey) {}
95586
+ // "maybeKey" is optional. It is acceptable to use "_jsx" without a third argument
95587
+ if (keyAttr) {
95588
+ args.push(transformJsxAttributeInitializer(keyAttr.initializer));
95589
+ }
95533
95590
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95534
95591
  var originalFile = ts.getOriginalNode(currentSourceFile);
95535
95592
  if (originalFile && ts.isSourceFile(originalFile)) {
95593
+ // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
95594
+ if (keyAttr === undefined) {
95595
+ args.push(factory.createVoidZero());
95596
+ }
95536
95597
  // isStaticChildren development flag
95537
95598
  args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95538
95599
  // __source development flag
@@ -119397,11 +119458,12 @@ var ts;
119397
119458
  };
119398
119459
  }
119399
119460
  function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
119461
+ var _a;
119400
119462
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
119401
119463
  && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
119402
119464
  return false;
119403
119465
  }
119404
- return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119466
+ return ts.getImpliedNodeFormatForFile(importingSourceFileName, (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host), getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119405
119467
  }
119406
119468
  function getModuleResolutionHost(host) {
119407
119469
  var _a;
@@ -119961,11 +120023,13 @@ var ts;
119961
120023
  // For classic resolution, only allow importing from node_modules/@types, not other node_modules
119962
120024
  return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
119963
120025
  function tryDirectoryWithPackageJson(packageRootIndex) {
120026
+ var _a, _b;
119964
120027
  var packageRootPath = path.substring(0, packageRootIndex);
119965
120028
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
119966
120029
  var moduleFileToTry = path;
119967
- if (host.fileExists(packageJsonPath)) {
119968
- var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
120030
+ var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
120031
+ if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
120032
+ var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
119969
120033
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119970
120034
  // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
119971
120035
  // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
@@ -120265,22 +120329,31 @@ var ts;
120265
120329
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
120266
120330
  }
120267
120331
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
120332
+ function prettyPathForFileError(error, cwd) {
120333
+ var line = ts.formatColorAndReset(":" + error.line, ts.ForegroundColorEscapeSequences.Grey);
120334
+ if (ts.pathIsAbsolute(error.fileName) && ts.pathIsAbsolute(cwd)) {
120335
+ return ts.getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
120336
+ }
120337
+ return error.fileName + line;
120338
+ }
120268
120339
  function getErrorSummaryText(errorCount, filesInError, newLine, host) {
120269
120340
  if (errorCount === 0)
120270
120341
  return "";
120271
120342
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
120272
120343
  var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; })
120273
120344
  .filter(function (value, index, self) { return self.indexOf(value) === index; });
120345
+ var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory());
120274
120346
  var d = errorCount === 1 ?
120275
120347
  ts.createCompilerDiagnostic(filesInError[0] !== undefined ?
120276
120348
  ts.Diagnostics.Found_1_error_in_1 :
120277
- ts.Diagnostics.Found_1_error, errorCount, distinctFileNamesWithLines[0]) :
120349
+ ts.Diagnostics.Found_1_error, errorCount, firstFileReference) :
120278
120350
  ts.createCompilerDiagnostic(distinctFileNamesWithLines.length === 0 ?
120279
120351
  ts.Diagnostics.Found_0_errors :
120280
120352
  distinctFileNamesWithLines.length === 1 ?
120281
- ts.Diagnostics.Found_0_errors_in_1_file :
120282
- ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
120283
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
120353
+ ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 :
120354
+ ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length);
120355
+ var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "";
120356
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix;
120284
120357
  }
120285
120358
  ts.getErrorSummaryText = getErrorSummaryText;
120286
120359
  function createTabularErrorsDisplay(filesInError, host) {
@@ -120302,8 +120375,8 @@ var ts;
120302
120375
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
120303
120376
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
120304
120377
  : "";
120305
- var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
120306
- tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
120378
+ var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
120379
+ tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n";
120307
120380
  });
120308
120381
  return tabularData;
120309
120382
  }
@@ -120804,6 +120877,7 @@ var ts;
120804
120877
  var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
120805
120878
  var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
120806
120879
  var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
120880
+ var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
120807
120881
  var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
120808
120882
  var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
120809
120883
  var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
@@ -120966,14 +121040,21 @@ var ts;
120966
121040
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
120967
121041
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
120968
121042
  if (hasChangedConfigFileParsingErrors) {
121043
+ if (reportFileChangeDetectedOnCreateProgram) {
121044
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121045
+ }
120969
121046
  builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
120970
121047
  hasChangedConfigFileParsingErrors = false;
120971
121048
  }
120972
121049
  }
120973
121050
  else {
121051
+ if (reportFileChangeDetectedOnCreateProgram) {
121052
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121053
+ }
120974
121054
  createNewProgram(hasInvalidatedResolution);
120975
121055
  }
120976
121056
  changesAffectResolution = false; // reset for next sync
121057
+ reportFileChangeDetectedOnCreateProgram = false;
120977
121058
  if (host.afterProgramCreate && program !== builderProgram) {
120978
121059
  host.afterProgramCreate(builderProgram);
120979
121060
  }
@@ -121175,7 +121256,7 @@ var ts;
121175
121256
  }
121176
121257
  function updateProgramWithWatchStatus() {
121177
121258
  timerToUpdateProgram = undefined;
121178
- reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121259
+ reportFileChangeDetectedOnCreateProgram = true;
121179
121260
  updateProgram();
121180
121261
  }
121181
121262
  function updateProgram() {
@@ -123282,6 +123363,7 @@ var ts;
123282
123363
  ScriptElementKind["externalModuleName"] = "external module name";
123283
123364
  /**
123284
123365
  * <JsxTagName attribute1 attribute2={0} />
123366
+ * @deprecated
123285
123367
  */
123286
123368
  ScriptElementKind["jsxAttribute"] = "JSX attribute";
123287
123369
  /** String literal */
@@ -124607,7 +124689,7 @@ var ts;
124607
124689
  isWhiteSpaceOnlyJsxText(child);
124608
124690
  if (lookInPreviousChild) {
124609
124691
  // actual start of the node is past the position - previous token should be at the end of previous child
124610
- var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile);
124692
+ var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
124611
124693
  return candidate_1 && findRightmostToken(candidate_1, sourceFile);
124612
124694
  }
124613
124695
  else {
@@ -124621,7 +124703,7 @@ var ts;
124621
124703
  // the only known case is when position is at the end of the file.
124622
124704
  // Try to find the rightmost token in the file without filtering.
124623
124705
  // Namely we are skipping the check: 'position < node.end'
124624
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
124706
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
124625
124707
  return candidate && findRightmostToken(candidate, sourceFile);
124626
124708
  }
124627
124709
  }
@@ -124637,17 +124719,19 @@ var ts;
124637
124719
  if (children.length === 0) {
124638
124720
  return n;
124639
124721
  }
124640
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
124722
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
124641
124723
  return candidate && findRightmostToken(candidate, sourceFile);
124642
124724
  }
124643
124725
  /**
124644
124726
  * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens.
124645
124727
  */
124646
- function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) {
124728
+ function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) {
124647
124729
  for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
124648
124730
  var child = children[i];
124649
124731
  if (isWhiteSpaceOnlyJsxText(child)) {
124650
- ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
124732
+ if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
124733
+ ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
124734
+ }
124651
124735
  }
124652
124736
  else if (nodeHasTokens(children[i], sourceFile)) {
124653
124737
  return children[i];
@@ -125173,6 +125257,7 @@ var ts;
125173
125257
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
125174
125258
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache,
125175
125259
  getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache),
125260
+ getPackageJsonInfoCache: function () { var _a; return (_a = program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); },
125176
125261
  getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation),
125177
125262
  redirectTargetsMap: program.redirectTargetsMap,
125178
125263
  getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); },
@@ -128917,6 +129002,7 @@ var ts;
128917
129002
  function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
128918
129003
  var _a, _b, _c;
128919
129004
  var start = ts.timestamp();
129005
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
128920
129006
  var resolutionLimitExceeded = false;
128921
129007
  var ambientCount = 0;
128922
129008
  var resolvedCount = 0;
@@ -128939,7 +129025,7 @@ var ts;
128939
129025
  var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
128940
129026
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
128941
129027
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
128942
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, shouldGetModuleSpecifierFromCache)
129028
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
128943
129029
  : undefined;
128944
129030
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
128945
129031
  resolutionLimitExceeded = true;
@@ -130337,9 +130423,7 @@ var ts;
130337
130423
  // GH#39946. Pulling on the type of a node inside of a function with a contextual `this` parameter can result in a circularity
130338
130424
  // if the `node` is part of the exprssion of a `yield` or `return`. This circularity doesn't exist at compile time because
130339
130425
  // we will check (and cache) the type of `this` *before* checking the type of the node.
130340
- var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
130341
- if (!ts.isSourceFile(container) && container.parent)
130342
- typeChecker.getTypeAtLocation(container);
130426
+ typeChecker.tryGetThisTypeAt(node, /*includeGlobalThis*/ false);
130343
130427
  var type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
130344
130428
  var insertQuestionDot = false;
130345
130429
  if (type.isNullableType()) {
@@ -133194,7 +133278,7 @@ var ts;
133194
133278
  ts.Debug.assert(parent.name === node);
133195
133279
  return true;
133196
133280
  case 202 /* BindingElement */:
133197
- return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent);
133281
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
133198
133282
  default:
133199
133283
  return false;
133200
133284
  }
@@ -133675,7 +133759,7 @@ var ts;
133675
133759
  function getTextSpan(node, sourceFile, endNode) {
133676
133760
  var start = node.getStart(sourceFile);
133677
133761
  var end = (endNode || node).getEnd();
133678
- if (ts.isStringLiteralLike(node)) {
133762
+ if (ts.isStringLiteralLike(node) && (end - start) > 2) {
133679
133763
  ts.Debug.assert(endNode === undefined);
133680
133764
  start += 1;
133681
133765
  end -= 1;
@@ -134594,7 +134678,7 @@ var ts;
134594
134678
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
134595
134679
  if (ts.isInJSFile(referenceLocation)
134596
134680
  && referenceLocation.parent.kind === 202 /* BindingElement */
134597
- && ts.isRequireVariableDeclaration(referenceLocation.parent)) {
134681
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
134598
134682
  referenceSymbol = referenceLocation.parent.symbol;
134599
134683
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
134600
134684
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -136305,7 +136389,7 @@ var ts;
136305
136389
  return declaration.parent.kind === 268 /* NamedImports */;
136306
136390
  case 202 /* BindingElement */:
136307
136391
  case 253 /* VariableDeclaration */:
136308
- return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration);
136392
+ return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
136309
136393
  default:
136310
136394
  return false;
136311
136395
  }
@@ -136995,7 +137079,7 @@ var ts;
136995
137079
  textSpan: ts.createTextSpanFromNode(declaration),
136996
137080
  // TODO(jfreeman): What should be the containerName when the container has a computed name?
136997
137081
  containerName: containerName ? containerName.text : "",
136998
- containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, // TODO: GH#18217 Just use `container ? ...`
137082
+ containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */,
136999
137083
  };
137000
137084
  }
137001
137085
  })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
@@ -141209,18 +141293,7 @@ var ts;
141209
141293
  }
141210
141294
  return unionPropertyKind;
141211
141295
  }
141212
- // If we requested completions after `x.` at the top-level, we may be at a source file location.
141213
- switch (location.parent && location.parent.kind) {
141214
- // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'.
141215
- case 279 /* JsxOpeningElement */:
141216
- case 277 /* JsxElement */:
141217
- case 278 /* JsxSelfClosingElement */:
141218
- return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */;
141219
- case 284 /* JsxAttribute */:
141220
- return "JSX attribute" /* jsxAttribute */;
141221
- default:
141222
- return "property" /* memberVariableElement */;
141223
- }
141296
+ return "property" /* memberVariableElement */;
141224
141297
  }
141225
141298
  return "" /* unknown */;
141226
141299
  }
@@ -149212,7 +149285,8 @@ var ts;
149212
149285
  codefix.getImportCompletionAction = getImportCompletionAction;
149213
149286
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149214
149287
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149215
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, host, preferences);
149288
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
149289
+ return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
149216
149290
  }
149217
149291
  function codeFixActionToCodeAction(_a) {
149218
149292
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -149267,12 +149341,12 @@ var ts;
149267
149341
  return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
149268
149342
  }
149269
149343
  }
149270
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, fromCacheOnly) {
149344
+ function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
149271
149345
  var _a = getNewImportFixes(program, importingFile,
149272
149346
  /*position*/ undefined,
149273
149347
  /*isValidTypeOnlyUseSite*/ false,
149274
149348
  /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
149275
- var result = getBestFix(fixes, importingFile, program, host, preferences);
149349
+ var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
149276
149350
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
149277
149351
  }
149278
149352
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
@@ -149406,7 +149480,7 @@ var ts;
149406
149480
  var importKind = getImportKind(importingFile, exportKind, compilerOptions);
149407
149481
  return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
149408
149482
  var i = ts.importFromModuleSpecifier(moduleSpecifier);
149409
- if (ts.isRequireVariableDeclaration(i.parent)) {
149483
+ if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
149410
149484
  return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
149411
149485
  }
149412
149486
  if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
@@ -149492,23 +149566,22 @@ var ts;
149492
149566
  var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
149493
149567
  ? getFixesInfoForUMDImport(context, symbolToken)
149494
149568
  : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
149495
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, context.host, context.preferences) });
149569
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
149570
+ return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
149496
149571
  }
149497
- function sortFixes(fixes, sourceFile, program, host, preferences) {
149498
- var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
149499
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, allowsImportingSpecifier); });
149572
+ function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
149573
+ return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier); });
149500
149574
  }
149501
- function getBestFix(fixes, sourceFile, program, host, preferences) {
149575
+ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
149502
149576
  if (!ts.some(fixes))
149503
149577
  return;
149504
149578
  // These will always be placed first if available, and are better than other kinds
149505
149579
  if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) {
149506
149580
  return fixes[0];
149507
149581
  }
149508
- var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
149509
149582
  return fixes.reduce(function (best, fix) {
149510
149583
  // Takes true branch of conditional if `fix` is better than `best`
149511
- return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
149584
+ return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
149512
149585
  });
149513
149586
  }
149514
149587
  /** @returns `Comparison.LessThan` if `a` is better than `b`. */
@@ -150132,7 +150205,7 @@ var ts;
150132
150205
  var errorCodes = [ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
150133
150206
  codefix.registerCodeFix({
150134
150207
  errorCodes: errorCodes,
150135
- getCodeActions: function (context) {
150208
+ getCodeActions: function getCodeActionsToFixImplicitThis(context) {
150136
150209
  var sourceFile = context.sourceFile, program = context.program, span = context.span;
150137
150210
  var diagnostic;
150138
150211
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -150147,7 +150220,8 @@ var ts;
150147
150220
  });
150148
150221
  function doChange(changes, sourceFile, pos, checker) {
150149
150222
  var token = ts.getTokenAtPosition(sourceFile, pos);
150150
- ts.Debug.assert(token.kind === 108 /* ThisKeyword */);
150223
+ if (!ts.isThis(token))
150224
+ return undefined;
150151
150225
  var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false);
150152
150226
  if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
150153
150227
  return undefined;
@@ -151957,6 +152031,9 @@ var ts;
151957
152031
  codefix.registerCodeFix({
151958
152032
  errorCodes: errorCodes,
151959
152033
  getCodeActions: function (context) {
152034
+ var syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
152035
+ if (syntacticDiagnostics.length)
152036
+ return;
151960
152037
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, context.span.start, context.span.length, context.errorCode); });
151961
152038
  return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Remove_unreachable_code, fixId, ts.Diagnostics.Remove_all_unreachable_code)];
151962
152039
  },
@@ -152360,7 +152437,7 @@ var ts;
152360
152437
  });
152361
152438
  var name = declaration && ts.getNameOfDeclaration(declaration);
152362
152439
  return !name || changes.length === 0 ? undefined
152363
- : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
152440
+ : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getTextOfNode(name)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
152364
152441
  },
152365
152442
  fixIds: [fixId],
152366
152443
  getAllCodeActions: function (context) {
@@ -152438,7 +152515,7 @@ var ts;
152438
152515
  case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: {
152439
152516
  var symbol = program.getTypeChecker().getSymbolAtLocation(token);
152440
152517
  if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) {
152441
- annotateVariableDeclaration(changes, importAdder, sourceFile, symbol.valueDeclaration, program, host, cancellationToken);
152518
+ annotateVariableDeclaration(changes, importAdder, ts.getSourceFileOfNode(symbol.valueDeclaration), symbol.valueDeclaration, program, host, cancellationToken);
152442
152519
  importAdder.writeFixes(changes);
152443
152520
  return symbol.valueDeclaration;
152444
152521
  }
@@ -160592,6 +160669,7 @@ var ts;
160592
160669
  ], false);
160593
160670
  function createLanguageService(host, documentRegistry, syntaxOnlyOrLanguageServiceMode) {
160594
160671
  var _a;
160672
+ var _b;
160595
160673
  if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); }
160596
160674
  var languageServiceMode;
160597
160675
  if (syntaxOnlyOrLanguageServiceMode === undefined) {
@@ -160612,10 +160690,8 @@ var ts;
160612
160690
  ? new CancellationTokenObject(host.getCancellationToken())
160613
160691
  : NoopCancellationToken;
160614
160692
  var currentDirectory = host.getCurrentDirectory();
160615
- // Check if the localized messages json is set, otherwise query the host for it
160616
- if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
160617
- ts.setLocalizedDiagnosticMessages(host.getLocalizedDiagnosticMessages());
160618
- }
160693
+ // Checks if the localized messages json is set, and if not, query the host for it
160694
+ ts.maybeSetLocalizedDiagnosticMessages((_b = host.getLocalizedDiagnosticMessages) === null || _b === void 0 ? void 0 : _b.bind(host));
160619
160695
  function log(message) {
160620
160696
  if (host.log) {
160621
160697
  host.log(message);
@@ -160717,6 +160793,7 @@ var ts;
160717
160793
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
160718
160794
  trace: parseConfigHost.trace,
160719
160795
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
160796
+ getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
160720
160797
  resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
160721
160798
  useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
160722
160799
  getParsedCommandLine: getParsedCommandLine,
@@ -165347,6 +165424,9 @@ var ts;
165347
165424
  Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference, _options, containingSourceFile) {
165348
165425
  return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile);
165349
165426
  };
165427
+ Project.prototype.getModuleResolutionCache = function () {
165428
+ return this.resolutionCache.getModuleResolutionCache();
165429
+ };
165350
165430
  Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
165351
165431
  return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
165352
165432
  };
@@ -166609,6 +166689,7 @@ var ts;
166609
166689
  if (!program) {
166610
166690
  return ts.emptyArray;
166611
166691
  }
166692
+ var start = ts.timestamp();
166612
166693
  var dependencyNames;
166613
166694
  var rootNames;
166614
166695
  var rootFileName = ts.combinePaths(hostProject.currentDirectory, ts.inferredTypesContainingFile);
@@ -166618,14 +166699,14 @@ var ts;
166618
166699
  (_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a.forEach(function (_, dependenyName) { return addDependency(dependenyName); });
166619
166700
  (_b = packageJson.peerDependencies) === null || _b === void 0 ? void 0 : _b.forEach(function (_, dependencyName) { return addDependency(dependencyName); });
166620
166701
  }
166702
+ var dependenciesAdded = 0;
166621
166703
  if (dependencyNames) {
166622
- var dependenciesAdded = 0;
166623
166704
  var symlinkCache = hostProject.getSymlinkCache();
166624
166705
  for (var _c = 0, _d = ts.arrayFrom(dependencyNames.keys()); _c < _d.length; _c++) {
166625
166706
  var name = _d[_c];
166626
166707
  // Avoid creating a large project that would significantly slow down time to editor interactivity
166627
166708
  if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this.maxDependencies) {
166628
- hostProject.log("Auto-import provider attempted to add more than " + this.maxDependencies + " dependencies.");
166709
+ hostProject.log("AutoImportProviderProject: attempted to add more than " + this.maxDependencies + " dependencies. Aborting.");
166629
166710
  return ts.emptyArray;
166630
166711
  }
166631
166712
  // 1. Try to load from the implementation package. For many dependencies, the
@@ -166659,6 +166740,9 @@ var ts;
166659
166740
  }
166660
166741
  }
166661
166742
  }
166743
+ if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) {
166744
+ hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms");
166745
+ }
166662
166746
  return rootNames || ts.emptyArray;
166663
166747
  function addDependency(dependency) {
166664
166748
  if (!ts.startsWith(dependency, "@types/")) {
@@ -166759,6 +166843,11 @@ var ts;
166759
166843
  return this.hostProject.getSymlinkCache();
166760
166844
  };
166761
166845
  /*@internal*/
166846
+ AutoImportProviderProject.prototype.getModuleResolutionCache = function () {
166847
+ var _a;
166848
+ return (_a = this.hostProject.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getModuleResolutionCache();
166849
+ };
166850
+ /*@internal*/
166762
166851
  AutoImportProviderProject.maxDependencies = 10;
166763
166852
  /*@internal*/
166764
166853
  AutoImportProviderProject.compilerOptionsOverrides = {