typescript 4.6.0-dev.20220119 → 4.6.0-dev.20220123

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.20220119";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220123";
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() {
@@ -45428,6 +45455,8 @@ var ts;
45428
45455
  return;
45429
45456
  }
45430
45457
  ts.setParent(node, parent);
45458
+ if (ts.tracing)
45459
+ node.tracingPath = file.path;
45431
45460
  var saveInStrictMode = inStrictMode;
45432
45461
  // Even though in the AST the jsdoc @typedef node belongs to the current node,
45433
45462
  // its symbol might be in the same scope with the current node's symbol. Consider:
@@ -46248,7 +46277,7 @@ var ts;
46248
46277
  checkStrictModeEvalOrArguments(node, node.name);
46249
46278
  }
46250
46279
  if (!ts.isBindingPattern(node.name)) {
46251
- if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) {
46280
+ if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
46252
46281
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
46253
46282
  }
46254
46283
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -46759,6 +46788,9 @@ var ts;
46759
46788
  TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
46760
46789
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46761
46790
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46791
+ // Masks
46792
+ TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46793
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46762
46794
  })(TypeFacts || (TypeFacts = {}));
46763
46795
  var typeofEQFacts = new ts.Map(ts.getEntries({
46764
46796
  string: 1 /* TypeofEQString */,
@@ -49031,7 +49063,7 @@ var ts;
49031
49063
  && isAliasableOrJsExpression(node.parent.right)
49032
49064
  || node.kind === 295 /* ShorthandPropertyAssignment */
49033
49065
  || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
49034
- || ts.isRequireVariableDeclaration(node);
49066
+ || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
49035
49067
  }
49036
49068
  function isAliasableOrJsExpression(e) {
49037
49069
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -49819,8 +49851,14 @@ var ts;
49819
49851
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49820
49852
  var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
49821
49853
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49822
- var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
49854
+ var sourceFile = resolvedModule
49855
+ && (!resolutionDiagnostic || resolutionDiagnostic === ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set)
49856
+ && host.getSourceFile(resolvedModule.resolvedFileName);
49823
49857
  if (sourceFile) {
49858
+ // If there's a resolutionDiagnostic we need to report it even if a sourceFile is found.
49859
+ if (resolutionDiagnostic) {
49860
+ error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
49861
+ }
49824
49862
  if (sourceFile.symbol) {
49825
49863
  if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
49826
49864
  errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
@@ -67894,10 +67932,23 @@ var ts;
67894
67932
  // When an intersection contains a primitive type we ignore object type constituents as they are
67895
67933
  // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
67896
67934
  ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
67897
- return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */);
67935
+ return getIntersectionTypeFacts(type, ignoreObjects);
67898
67936
  }
67899
67937
  return 16777215 /* All */;
67900
67938
  }
67939
+ function getIntersectionTypeFacts(type, ignoreObjects) {
67940
+ // When computing the type facts of an intersection type, certain type facts are computed as `and`
67941
+ // and others are computed as `or`.
67942
+ var oredFacts = 0 /* None */;
67943
+ var andedFacts = 16777215 /* All */;
67944
+ for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
67945
+ var t = _a[_i];
67946
+ var f = getTypeFacts(t, ignoreObjects);
67947
+ oredFacts |= f;
67948
+ andedFacts &= f;
67949
+ }
67950
+ return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
67951
+ }
67901
67952
  function getTypeWithFacts(type, include) {
67902
67953
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
67903
67954
  }
@@ -77909,7 +77960,7 @@ var ts;
77909
77960
  }
77910
77961
  }
77911
77962
  function checkExpression(node, checkMode, forceTuple) {
77912
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
77963
+ 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 });
77913
77964
  var saveCurrentNode = currentNode;
77914
77965
  currentNode = node;
77915
77966
  instantiationCount = 0;
@@ -80590,7 +80641,7 @@ var ts;
80590
80641
  }
80591
80642
  // For a commonjs `const x = require`, validate the alias and exit
80592
80643
  var symbol = getSymbolOfNode(node);
80593
- if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) {
80644
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
80594
80645
  checkAliasSymbol(node);
80595
80646
  return;
80596
80647
  }
@@ -80668,7 +80719,7 @@ var ts;
80668
80719
  return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
80669
80720
  }
80670
80721
  function checkVariableDeclaration(node) {
80671
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
80722
+ 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 });
80672
80723
  checkGrammarVariableDeclaration(node);
80673
80724
  checkVariableLikeDeclaration(node);
80674
80725
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -83058,6 +83109,17 @@ var ts;
83058
83109
  return false;
83059
83110
  }
83060
83111
  }
83112
+ if (!ts.isImportEqualsDeclaration(node) && node.assertClause) {
83113
+ var hasError = false;
83114
+ for (var _i = 0, _a = node.assertClause.elements; _i < _a.length; _i++) {
83115
+ var clause = _a[_i];
83116
+ if (!ts.isStringLiteral(clause.value)) {
83117
+ hasError = true;
83118
+ error(clause.value, ts.Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
83119
+ }
83120
+ }
83121
+ return !hasError;
83122
+ }
83061
83123
  return true;
83062
83124
  }
83063
83125
  function checkAliasSymbol(node) {
@@ -83751,7 +83813,7 @@ var ts;
83751
83813
  }
83752
83814
  }
83753
83815
  function checkDeferredNode(node) {
83754
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
83816
+ 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 });
83755
83817
  var saveCurrentNode = currentNode;
83756
83818
  currentNode = node;
83757
83819
  instantiationCount = 0;
@@ -87685,7 +87747,7 @@ var ts;
87685
87747
  return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine);
87686
87748
  case 293 /* AssertEntry */:
87687
87749
  ts.Debug.type(node);
87688
- return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isStringLiteral));
87750
+ return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode));
87689
87751
  case 266 /* ImportClause */:
87690
87752
  ts.Debug.type(node);
87691
87753
  return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
@@ -120283,22 +120345,31 @@ var ts;
120283
120345
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
120284
120346
  }
120285
120347
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
120348
+ function prettyPathForFileError(error, cwd) {
120349
+ var line = ts.formatColorAndReset(":" + error.line, ts.ForegroundColorEscapeSequences.Grey);
120350
+ if (ts.pathIsAbsolute(error.fileName) && ts.pathIsAbsolute(cwd)) {
120351
+ return ts.getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
120352
+ }
120353
+ return error.fileName + line;
120354
+ }
120286
120355
  function getErrorSummaryText(errorCount, filesInError, newLine, host) {
120287
120356
  if (errorCount === 0)
120288
120357
  return "";
120289
120358
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
120290
120359
  var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; })
120291
120360
  .filter(function (value, index, self) { return self.indexOf(value) === index; });
120361
+ var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory());
120292
120362
  var d = errorCount === 1 ?
120293
120363
  ts.createCompilerDiagnostic(filesInError[0] !== undefined ?
120294
120364
  ts.Diagnostics.Found_1_error_in_1 :
120295
- ts.Diagnostics.Found_1_error, errorCount, distinctFileNamesWithLines[0]) :
120365
+ ts.Diagnostics.Found_1_error, errorCount, firstFileReference) :
120296
120366
  ts.createCompilerDiagnostic(distinctFileNamesWithLines.length === 0 ?
120297
120367
  ts.Diagnostics.Found_0_errors :
120298
120368
  distinctFileNamesWithLines.length === 1 ?
120299
- ts.Diagnostics.Found_0_errors_in_1_file :
120300
- ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
120301
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
120369
+ ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 :
120370
+ ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length);
120371
+ var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "";
120372
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix;
120302
120373
  }
120303
120374
  ts.getErrorSummaryText = getErrorSummaryText;
120304
120375
  function createTabularErrorsDisplay(filesInError, host) {
@@ -120320,8 +120391,8 @@ var ts;
120320
120391
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
120321
120392
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
120322
120393
  : "";
120323
- var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
120324
- tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
120394
+ var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
120395
+ tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n";
120325
120396
  });
120326
120397
  return tabularData;
120327
120398
  }
@@ -124634,7 +124705,7 @@ var ts;
124634
124705
  isWhiteSpaceOnlyJsxText(child);
124635
124706
  if (lookInPreviousChild) {
124636
124707
  // actual start of the node is past the position - previous token should be at the end of previous child
124637
- var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile);
124708
+ var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
124638
124709
  return candidate_1 && findRightmostToken(candidate_1, sourceFile);
124639
124710
  }
124640
124711
  else {
@@ -124648,7 +124719,7 @@ var ts;
124648
124719
  // the only known case is when position is at the end of the file.
124649
124720
  // Try to find the rightmost token in the file without filtering.
124650
124721
  // Namely we are skipping the check: 'position < node.end'
124651
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
124722
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
124652
124723
  return candidate && findRightmostToken(candidate, sourceFile);
124653
124724
  }
124654
124725
  }
@@ -124664,17 +124735,19 @@ var ts;
124664
124735
  if (children.length === 0) {
124665
124736
  return n;
124666
124737
  }
124667
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
124738
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
124668
124739
  return candidate && findRightmostToken(candidate, sourceFile);
124669
124740
  }
124670
124741
  /**
124671
124742
  * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens.
124672
124743
  */
124673
- function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) {
124744
+ function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) {
124674
124745
  for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
124675
124746
  var child = children[i];
124676
124747
  if (isWhiteSpaceOnlyJsxText(child)) {
124677
- ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
124748
+ if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
124749
+ ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
124750
+ }
124678
124751
  }
124679
124752
  else if (nodeHasTokens(children[i], sourceFile)) {
124680
124753
  return children[i];
@@ -133221,7 +133294,7 @@ var ts;
133221
133294
  ts.Debug.assert(parent.name === node);
133222
133295
  return true;
133223
133296
  case 202 /* BindingElement */:
133224
- return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent);
133297
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
133225
133298
  default:
133226
133299
  return false;
133227
133300
  }
@@ -133702,7 +133775,7 @@ var ts;
133702
133775
  function getTextSpan(node, sourceFile, endNode) {
133703
133776
  var start = node.getStart(sourceFile);
133704
133777
  var end = (endNode || node).getEnd();
133705
- if (ts.isStringLiteralLike(node)) {
133778
+ if (ts.isStringLiteralLike(node) && (end - start) > 2) {
133706
133779
  ts.Debug.assert(endNode === undefined);
133707
133780
  start += 1;
133708
133781
  end -= 1;
@@ -134621,7 +134694,7 @@ var ts;
134621
134694
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
134622
134695
  if (ts.isInJSFile(referenceLocation)
134623
134696
  && referenceLocation.parent.kind === 202 /* BindingElement */
134624
- && ts.isRequireVariableDeclaration(referenceLocation.parent)) {
134697
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
134625
134698
  referenceSymbol = referenceLocation.parent.symbol;
134626
134699
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
134627
134700
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -136222,7 +136295,7 @@ var ts;
136222
136295
  return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false };
136223
136296
  }
136224
136297
  if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) {
136225
- var node = ts.getTokenAtPosition(sourceFile, position);
136298
+ var node = ts.getTouchingToken(sourceFile, position);
136226
136299
  if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) {
136227
136300
  var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
136228
136301
  var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text);
@@ -136332,7 +136405,7 @@ var ts;
136332
136405
  return declaration.parent.kind === 268 /* NamedImports */;
136333
136406
  case 202 /* BindingElement */:
136334
136407
  case 253 /* VariableDeclaration */:
136335
- return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration);
136408
+ return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
136336
136409
  default:
136337
136410
  return false;
136338
136411
  }
@@ -137022,7 +137095,7 @@ var ts;
137022
137095
  textSpan: ts.createTextSpanFromNode(declaration),
137023
137096
  // TODO(jfreeman): What should be the containerName when the container has a computed name?
137024
137097
  containerName: containerName ? containerName.text : "",
137025
- containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, // TODO: GH#18217 Just use `container ? ...`
137098
+ containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */,
137026
137099
  };
137027
137100
  }
137028
137101
  })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
@@ -149423,7 +149496,7 @@ var ts;
149423
149496
  var importKind = getImportKind(importingFile, exportKind, compilerOptions);
149424
149497
  return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
149425
149498
  var i = ts.importFromModuleSpecifier(moduleSpecifier);
149426
- if (ts.isRequireVariableDeclaration(i.parent)) {
149499
+ if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
149427
149500
  return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
149428
149501
  }
149429
149502
  if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
@@ -150148,7 +150221,7 @@ var ts;
150148
150221
  var errorCodes = [ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
150149
150222
  codefix.registerCodeFix({
150150
150223
  errorCodes: errorCodes,
150151
- getCodeActions: function (context) {
150224
+ getCodeActions: function getCodeActionsToFixImplicitThis(context) {
150152
150225
  var sourceFile = context.sourceFile, program = context.program, span = context.span;
150153
150226
  var diagnostic;
150154
150227
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -150163,7 +150236,8 @@ var ts;
150163
150236
  });
150164
150237
  function doChange(changes, sourceFile, pos, checker) {
150165
150238
  var token = ts.getTokenAtPosition(sourceFile, pos);
150166
- ts.Debug.assert(token.kind === 108 /* ThisKeyword */);
150239
+ if (!ts.isThis(token))
150240
+ return undefined;
150167
150241
  var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false);
150168
150242
  if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
150169
150243
  return undefined;
@@ -151973,6 +152047,9 @@ var ts;
151973
152047
  codefix.registerCodeFix({
151974
152048
  errorCodes: errorCodes,
151975
152049
  getCodeActions: function (context) {
152050
+ var syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
152051
+ if (syntacticDiagnostics.length)
152052
+ return;
151976
152053
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, context.span.start, context.span.length, context.errorCode); });
151977
152054
  return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Remove_unreachable_code, fixId, ts.Diagnostics.Remove_all_unreachable_code)];
151978
152055
  },
@@ -160608,6 +160685,7 @@ var ts;
160608
160685
  ], false);
160609
160686
  function createLanguageService(host, documentRegistry, syntaxOnlyOrLanguageServiceMode) {
160610
160687
  var _a;
160688
+ var _b;
160611
160689
  if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); }
160612
160690
  var languageServiceMode;
160613
160691
  if (syntaxOnlyOrLanguageServiceMode === undefined) {
@@ -160628,10 +160706,8 @@ var ts;
160628
160706
  ? new CancellationTokenObject(host.getCancellationToken())
160629
160707
  : NoopCancellationToken;
160630
160708
  var currentDirectory = host.getCurrentDirectory();
160631
- // Check if the localized messages json is set, otherwise query the host for it
160632
- if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
160633
- ts.setLocalizedDiagnosticMessages(host.getLocalizedDiagnosticMessages());
160634
- }
160709
+ // Checks if the localized messages json is set, and if not, query the host for it
160710
+ ts.maybeSetLocalizedDiagnosticMessages((_b = host.getLocalizedDiagnosticMessages) === null || _b === void 0 ? void 0 : _b.bind(host));
160635
160711
  function log(message) {
160636
160712
  if (host.log) {
160637
160713
  host.log(message);
@@ -1652,7 +1652,7 @@ declare namespace ts {
1652
1652
  readonly kind: SyntaxKind.AssertEntry;
1653
1653
  readonly parent: AssertClause;
1654
1654
  readonly name: AssertionKey;
1655
- readonly value: StringLiteral;
1655
+ readonly value: Expression;
1656
1656
  }
1657
1657
  export interface AssertClause extends Node {
1658
1658
  readonly kind: SyntaxKind.AssertClause;
@@ -3576,8 +3576,8 @@ declare namespace ts {
3576
3576
  updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
3577
3577
  createAssertClause(elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
3578
3578
  updateAssertClause(node: AssertClause, elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
3579
- createAssertEntry(name: AssertionKey, value: StringLiteral): AssertEntry;
3580
- updateAssertEntry(node: AssertEntry, name: AssertionKey, value: StringLiteral): AssertEntry;
3579
+ createAssertEntry(name: AssertionKey, value: Expression): AssertEntry;
3580
+ updateAssertEntry(node: AssertEntry, name: AssertionKey, value: Expression): AssertEntry;
3581
3581
  createNamespaceImport(name: Identifier): NamespaceImport;
3582
3582
  updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport;
3583
3583
  createNamespaceExport(name: Identifier): NamespaceExport;