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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220119";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220123";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -7004,11 +7004,15 @@ var ts;
7004
7004
  ts.getFileWatcherEventKind = getFileWatcherEventKind;
7005
7005
  /*@internal*/
7006
7006
  ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
7007
+ var curSysLog = ts.noop; // eslint-disable-line prefer-const
7007
7008
  /*@internal*/
7008
- ts.sysLog = ts.noop; // eslint-disable-line prefer-const
7009
+ function sysLog(s) {
7010
+ return curSysLog(s);
7011
+ }
7012
+ ts.sysLog = sysLog;
7009
7013
  /*@internal*/
7010
7014
  function setSysLog(logger) {
7011
- ts.sysLog = logger;
7015
+ curSysLog = logger;
7012
7016
  }
7013
7017
  ts.setSysLog = setSysLog;
7014
7018
  /**
@@ -7143,7 +7147,7 @@ var ts;
7143
7147
  }
7144
7148
  function onTimerToUpdateChildWatches() {
7145
7149
  timerToUpdateChildWatches = undefined;
7146
- ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
7150
+ sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
7147
7151
  var start = ts.timestamp();
7148
7152
  var invokeMap = new ts.Map();
7149
7153
  while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
@@ -7156,7 +7160,7 @@ var ts;
7156
7160
  var hasChanges = updateChildWatches(dirName, dirPath, options);
7157
7161
  invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
7158
7162
  }
7159
- ts.sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
7163
+ sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
7160
7164
  callbackCache.forEach(function (callbacks, rootDirName) {
7161
7165
  var existing = invokeMap.get(rootDirName);
7162
7166
  if (existing) {
@@ -7172,7 +7176,7 @@ var ts;
7172
7176
  }
7173
7177
  });
7174
7178
  var elapsed = ts.timestamp() - start;
7175
- ts.sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
7179
+ sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
7176
7180
  }
7177
7181
  function removeChildWatches(parentWatcher) {
7178
7182
  if (!parentWatcher)
@@ -7759,7 +7763,7 @@ var ts;
7759
7763
  * @param createWatcher
7760
7764
  */
7761
7765
  function invokeCallbackAndUpdateWatcher(createWatcher) {
7762
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7766
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7763
7767
  // Call the callback for current directory
7764
7768
  callback("rename", "");
7765
7769
  // If watcher is not closed, update it
@@ -7784,7 +7788,7 @@ var ts;
7784
7788
  }
7785
7789
  }
7786
7790
  if (hitSystemWatcherLimit) {
7787
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7791
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7788
7792
  return watchPresentFileSystemEntryWithFsWatchFile();
7789
7793
  }
7790
7794
  try {
@@ -7800,7 +7804,7 @@ var ts;
7800
7804
  // 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
7801
7805
  // so instead of throwing error, use fs.watchFile
7802
7806
  hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7803
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7807
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7804
7808
  return watchPresentFileSystemEntryWithFsWatchFile();
7805
7809
  }
7806
7810
  }
@@ -8399,6 +8403,7 @@ var ts;
8399
8403
  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"),
8400
8404
  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."),
8401
8405
  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."),
8406
+ catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8402
8407
  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."),
8403
8408
  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."),
8404
8409
  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),
@@ -8886,6 +8891,7 @@ var ts;
8886
8891
  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."),
8887
8892
  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}'?"),
8888
8893
  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."),
8894
+ 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."),
8889
8895
  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}'."),
8890
8896
  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}'."),
8891
8897
  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}'."),
@@ -9279,7 +9285,7 @@ var ts;
9279
9285
  Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
9280
9286
  _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"),
9281
9287
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
9282
- Found_0_errors_in_1_file: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_file_6260", "Found {0} errors in 1 file."),
9288
+ 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}"),
9283
9289
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
9284
9290
  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."),
9285
9291
  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}'."),
@@ -16052,7 +16058,7 @@ var ts;
16052
16058
  }
16053
16059
  ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
16054
16060
  function getExternalModuleRequireArgument(node) {
16055
- return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
16061
+ return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
16056
16062
  }
16057
16063
  ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
16058
16064
  function isInternalModuleImportEqualsDeclaration(node) {
@@ -16110,17 +16116,29 @@ var ts;
16110
16116
  * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`).
16111
16117
  * This function does not test if the node is in a JavaScript file or not.
16112
16118
  */
16113
- function isRequireVariableDeclaration(node) {
16119
+ function isVariableDeclarationInitializedToRequire(node) {
16120
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false);
16121
+ }
16122
+ ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
16123
+ /**
16124
+ * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`.
16125
+ */
16126
+ function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
16127
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true);
16128
+ }
16129
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16130
+ function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16114
16131
  if (node.kind === 202 /* BindingElement */) {
16115
16132
  node = node.parent.parent;
16116
16133
  }
16117
- return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true);
16134
+ return ts.isVariableDeclaration(node) &&
16135
+ !!node.initializer &&
16136
+ isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
16118
16137
  }
16119
- ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
16120
16138
  function isRequireVariableStatement(node) {
16121
16139
  return ts.isVariableStatement(node)
16122
16140
  && node.declarationList.declarations.length > 0
16123
- && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); });
16141
+ && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
16124
16142
  }
16125
16143
  ts.isRequireVariableStatement = isRequireVariableStatement;
16126
16144
  function isSingleOrDoubleQuote(charCode) {
@@ -19607,7 +19625,7 @@ var ts;
19607
19625
  getSourceMapSourceConstructor: function () { return SourceMapSource; },
19608
19626
  };
19609
19627
  function setObjectAllocator(alloc) {
19610
- ts.objectAllocator = alloc;
19628
+ Object.assign(ts.objectAllocator, alloc);
19611
19629
  }
19612
19630
  ts.setObjectAllocator = setObjectAllocator;
19613
19631
  function formatStringFromArgs(text, args, baseIndex) {
@@ -19615,13 +19633,22 @@ var ts;
19615
19633
  return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
19616
19634
  }
19617
19635
  ts.formatStringFromArgs = formatStringFromArgs;
19636
+ var localizedDiagnosticMessages;
19618
19637
  /* @internal */
19619
19638
  function setLocalizedDiagnosticMessages(messages) {
19620
- ts.localizedDiagnosticMessages = messages;
19639
+ localizedDiagnosticMessages = messages;
19621
19640
  }
19622
19641
  ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
19642
+ /* @internal */
19643
+ // If the localized messages json is unset, and if given function use it to set the json
19644
+ function maybeSetLocalizedDiagnosticMessages(getMessages) {
19645
+ if (!localizedDiagnosticMessages && getMessages) {
19646
+ localizedDiagnosticMessages = getMessages();
19647
+ }
19648
+ }
19649
+ ts.maybeSetLocalizedDiagnosticMessages = maybeSetLocalizedDiagnosticMessages;
19623
19650
  function getLocaleSpecificMessage(message) {
19624
- return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
19651
+ return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
19625
19652
  }
19626
19653
  ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
19627
19654
  function createDetachedDiagnostic(fileName, start, length, message) {
@@ -35230,7 +35257,7 @@ var ts;
35230
35257
  // one out no matter what.
35231
35258
  var finallyBlock;
35232
35259
  if (!catchClause || token() === 96 /* FinallyKeyword */) {
35233
- parseExpected(96 /* FinallyKeyword */);
35260
+ parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
35234
35261
  finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
35235
35262
  }
35236
35263
  return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
@@ -36274,7 +36301,7 @@ var ts;
36274
36301
  var pos = getNodePos();
36275
36302
  var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
36276
36303
  parseExpected(58 /* ColonToken */);
36277
- var value = parseLiteralLikeNode(10 /* StringLiteral */);
36304
+ var value = parseAssignmentExpressionOrHigher();
36278
36305
  return finishNode(factory.createAssertEntry(name, value), pos);
36279
36306
  }
36280
36307
  function parseAssertClause() {
@@ -45622,6 +45649,8 @@ var ts;
45622
45649
  return;
45623
45650
  }
45624
45651
  ts.setParent(node, parent);
45652
+ if (ts.tracing)
45653
+ node.tracingPath = file.path;
45625
45654
  var saveInStrictMode = inStrictMode;
45626
45655
  // Even though in the AST the jsdoc @typedef node belongs to the current node,
45627
45656
  // its symbol might be in the same scope with the current node's symbol. Consider:
@@ -46442,7 +46471,7 @@ var ts;
46442
46471
  checkStrictModeEvalOrArguments(node, node.name);
46443
46472
  }
46444
46473
  if (!ts.isBindingPattern(node.name)) {
46445
- if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) {
46474
+ if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
46446
46475
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
46447
46476
  }
46448
46477
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -46953,6 +46982,9 @@ var ts;
46953
46982
  TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
46954
46983
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46955
46984
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46985
+ // Masks
46986
+ TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46987
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46956
46988
  })(TypeFacts || (TypeFacts = {}));
46957
46989
  var typeofEQFacts = new ts.Map(ts.getEntries({
46958
46990
  string: 1 /* TypeofEQString */,
@@ -49225,7 +49257,7 @@ var ts;
49225
49257
  && isAliasableOrJsExpression(node.parent.right)
49226
49258
  || node.kind === 295 /* ShorthandPropertyAssignment */
49227
49259
  || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
49228
- || ts.isRequireVariableDeclaration(node);
49260
+ || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
49229
49261
  }
49230
49262
  function isAliasableOrJsExpression(e) {
49231
49263
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50013,8 +50045,14 @@ var ts;
50013
50045
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
50014
50046
  var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
50015
50047
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
50016
- var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
50048
+ var sourceFile = resolvedModule
50049
+ && (!resolutionDiagnostic || resolutionDiagnostic === ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set)
50050
+ && host.getSourceFile(resolvedModule.resolvedFileName);
50017
50051
  if (sourceFile) {
50052
+ // If there's a resolutionDiagnostic we need to report it even if a sourceFile is found.
50053
+ if (resolutionDiagnostic) {
50054
+ error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
50055
+ }
50018
50056
  if (sourceFile.symbol) {
50019
50057
  if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
50020
50058
  errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
@@ -68088,10 +68126,23 @@ var ts;
68088
68126
  // When an intersection contains a primitive type we ignore object type constituents as they are
68089
68127
  // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
68090
68128
  ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
68091
- return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */);
68129
+ return getIntersectionTypeFacts(type, ignoreObjects);
68092
68130
  }
68093
68131
  return 16777215 /* All */;
68094
68132
  }
68133
+ function getIntersectionTypeFacts(type, ignoreObjects) {
68134
+ // When computing the type facts of an intersection type, certain type facts are computed as `and`
68135
+ // and others are computed as `or`.
68136
+ var oredFacts = 0 /* None */;
68137
+ var andedFacts = 16777215 /* All */;
68138
+ for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
68139
+ var t = _a[_i];
68140
+ var f = getTypeFacts(t, ignoreObjects);
68141
+ oredFacts |= f;
68142
+ andedFacts &= f;
68143
+ }
68144
+ return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68145
+ }
68095
68146
  function getTypeWithFacts(type, include) {
68096
68147
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
68097
68148
  }
@@ -78103,7 +78154,7 @@ var ts;
78103
78154
  }
78104
78155
  }
78105
78156
  function checkExpression(node, checkMode, forceTuple) {
78106
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
78157
+ 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 });
78107
78158
  var saveCurrentNode = currentNode;
78108
78159
  currentNode = node;
78109
78160
  instantiationCount = 0;
@@ -80784,7 +80835,7 @@ var ts;
80784
80835
  }
80785
80836
  // For a commonjs `const x = require`, validate the alias and exit
80786
80837
  var symbol = getSymbolOfNode(node);
80787
- if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) {
80838
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
80788
80839
  checkAliasSymbol(node);
80789
80840
  return;
80790
80841
  }
@@ -80862,7 +80913,7 @@ var ts;
80862
80913
  return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
80863
80914
  }
80864
80915
  function checkVariableDeclaration(node) {
80865
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
80916
+ 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 });
80866
80917
  checkGrammarVariableDeclaration(node);
80867
80918
  checkVariableLikeDeclaration(node);
80868
80919
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -83252,6 +83303,17 @@ var ts;
83252
83303
  return false;
83253
83304
  }
83254
83305
  }
83306
+ if (!ts.isImportEqualsDeclaration(node) && node.assertClause) {
83307
+ var hasError = false;
83308
+ for (var _i = 0, _a = node.assertClause.elements; _i < _a.length; _i++) {
83309
+ var clause = _a[_i];
83310
+ if (!ts.isStringLiteral(clause.value)) {
83311
+ hasError = true;
83312
+ error(clause.value, ts.Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
83313
+ }
83314
+ }
83315
+ return !hasError;
83316
+ }
83255
83317
  return true;
83256
83318
  }
83257
83319
  function checkAliasSymbol(node) {
@@ -83945,7 +84007,7 @@ var ts;
83945
84007
  }
83946
84008
  }
83947
84009
  function checkDeferredNode(node) {
83948
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
84010
+ 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 });
83949
84011
  var saveCurrentNode = currentNode;
83950
84012
  currentNode = node;
83951
84013
  instantiationCount = 0;
@@ -87879,7 +87941,7 @@ var ts;
87879
87941
  return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine);
87880
87942
  case 293 /* AssertEntry */:
87881
87943
  ts.Debug.type(node);
87882
- return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isStringLiteral));
87944
+ return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode));
87883
87945
  case 266 /* ImportClause */:
87884
87946
  ts.Debug.type(node);
87885
87947
  return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
@@ -120477,22 +120539,31 @@ var ts;
120477
120539
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
120478
120540
  }
120479
120541
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
120542
+ function prettyPathForFileError(error, cwd) {
120543
+ var line = ts.formatColorAndReset(":" + error.line, ts.ForegroundColorEscapeSequences.Grey);
120544
+ if (ts.pathIsAbsolute(error.fileName) && ts.pathIsAbsolute(cwd)) {
120545
+ return ts.getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
120546
+ }
120547
+ return error.fileName + line;
120548
+ }
120480
120549
  function getErrorSummaryText(errorCount, filesInError, newLine, host) {
120481
120550
  if (errorCount === 0)
120482
120551
  return "";
120483
120552
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
120484
120553
  var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; })
120485
120554
  .filter(function (value, index, self) { return self.indexOf(value) === index; });
120555
+ var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory());
120486
120556
  var d = errorCount === 1 ?
120487
120557
  ts.createCompilerDiagnostic(filesInError[0] !== undefined ?
120488
120558
  ts.Diagnostics.Found_1_error_in_1 :
120489
- ts.Diagnostics.Found_1_error, errorCount, distinctFileNamesWithLines[0]) :
120559
+ ts.Diagnostics.Found_1_error, errorCount, firstFileReference) :
120490
120560
  ts.createCompilerDiagnostic(distinctFileNamesWithLines.length === 0 ?
120491
120561
  ts.Diagnostics.Found_0_errors :
120492
120562
  distinctFileNamesWithLines.length === 1 ?
120493
- ts.Diagnostics.Found_0_errors_in_1_file :
120494
- ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
120495
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
120563
+ ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 :
120564
+ ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length);
120565
+ var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "";
120566
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix;
120496
120567
  }
120497
120568
  ts.getErrorSummaryText = getErrorSummaryText;
120498
120569
  function createTabularErrorsDisplay(filesInError, host) {
@@ -120514,8 +120585,8 @@ var ts;
120514
120585
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
120515
120586
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
120516
120587
  : "";
120517
- var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
120518
- tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
120588
+ var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
120589
+ tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n";
120519
120590
  });
120520
120591
  return tabularData;
120521
120592
  }
@@ -125245,7 +125316,7 @@ var ts;
125245
125316
  isWhiteSpaceOnlyJsxText(child);
125246
125317
  if (lookInPreviousChild) {
125247
125318
  // actual start of the node is past the position - previous token should be at the end of previous child
125248
- var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile);
125319
+ var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
125249
125320
  return candidate_1 && findRightmostToken(candidate_1, sourceFile);
125250
125321
  }
125251
125322
  else {
@@ -125259,7 +125330,7 @@ var ts;
125259
125330
  // the only known case is when position is at the end of the file.
125260
125331
  // Try to find the rightmost token in the file without filtering.
125261
125332
  // Namely we are skipping the check: 'position < node.end'
125262
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
125333
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
125263
125334
  return candidate && findRightmostToken(candidate, sourceFile);
125264
125335
  }
125265
125336
  }
@@ -125275,17 +125346,19 @@ var ts;
125275
125346
  if (children.length === 0) {
125276
125347
  return n;
125277
125348
  }
125278
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
125349
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
125279
125350
  return candidate && findRightmostToken(candidate, sourceFile);
125280
125351
  }
125281
125352
  /**
125282
125353
  * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens.
125283
125354
  */
125284
- function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) {
125355
+ function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) {
125285
125356
  for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
125286
125357
  var child = children[i];
125287
125358
  if (isWhiteSpaceOnlyJsxText(child)) {
125288
- ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
125359
+ if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
125360
+ ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
125361
+ }
125289
125362
  }
125290
125363
  else if (nodeHasTokens(children[i], sourceFile)) {
125291
125364
  return children[i];
@@ -133832,7 +133905,7 @@ var ts;
133832
133905
  ts.Debug.assert(parent.name === node);
133833
133906
  return true;
133834
133907
  case 202 /* BindingElement */:
133835
- return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent);
133908
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
133836
133909
  default:
133837
133910
  return false;
133838
133911
  }
@@ -134313,7 +134386,7 @@ var ts;
134313
134386
  function getTextSpan(node, sourceFile, endNode) {
134314
134387
  var start = node.getStart(sourceFile);
134315
134388
  var end = (endNode || node).getEnd();
134316
- if (ts.isStringLiteralLike(node)) {
134389
+ if (ts.isStringLiteralLike(node) && (end - start) > 2) {
134317
134390
  ts.Debug.assert(endNode === undefined);
134318
134391
  start += 1;
134319
134392
  end -= 1;
@@ -135232,7 +135305,7 @@ var ts;
135232
135305
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
135233
135306
  if (ts.isInJSFile(referenceLocation)
135234
135307
  && referenceLocation.parent.kind === 202 /* BindingElement */
135235
- && ts.isRequireVariableDeclaration(referenceLocation.parent)) {
135308
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
135236
135309
  referenceSymbol = referenceLocation.parent.symbol;
135237
135310
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
135238
135311
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -136833,7 +136906,7 @@ var ts;
136833
136906
  return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false };
136834
136907
  }
136835
136908
  if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) {
136836
- var node = ts.getTokenAtPosition(sourceFile, position);
136909
+ var node = ts.getTouchingToken(sourceFile, position);
136837
136910
  if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) {
136838
136911
  var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
136839
136912
  var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text);
@@ -136943,7 +137016,7 @@ var ts;
136943
137016
  return declaration.parent.kind === 268 /* NamedImports */;
136944
137017
  case 202 /* BindingElement */:
136945
137018
  case 253 /* VariableDeclaration */:
136946
- return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration);
137019
+ return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
136947
137020
  default:
136948
137021
  return false;
136949
137022
  }
@@ -137633,7 +137706,7 @@ var ts;
137633
137706
  textSpan: ts.createTextSpanFromNode(declaration),
137634
137707
  // TODO(jfreeman): What should be the containerName when the container has a computed name?
137635
137708
  containerName: containerName ? containerName.text : "",
137636
- containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, // TODO: GH#18217 Just use `container ? ...`
137709
+ containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */,
137637
137710
  };
137638
137711
  }
137639
137712
  })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
@@ -150034,7 +150107,7 @@ var ts;
150034
150107
  var importKind = getImportKind(importingFile, exportKind, compilerOptions);
150035
150108
  return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
150036
150109
  var i = ts.importFromModuleSpecifier(moduleSpecifier);
150037
- if (ts.isRequireVariableDeclaration(i.parent)) {
150110
+ if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
150038
150111
  return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
150039
150112
  }
150040
150113
  if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
@@ -150759,7 +150832,7 @@ var ts;
150759
150832
  var errorCodes = [ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
150760
150833
  codefix.registerCodeFix({
150761
150834
  errorCodes: errorCodes,
150762
- getCodeActions: function (context) {
150835
+ getCodeActions: function getCodeActionsToFixImplicitThis(context) {
150763
150836
  var sourceFile = context.sourceFile, program = context.program, span = context.span;
150764
150837
  var diagnostic;
150765
150838
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -150774,7 +150847,8 @@ var ts;
150774
150847
  });
150775
150848
  function doChange(changes, sourceFile, pos, checker) {
150776
150849
  var token = ts.getTokenAtPosition(sourceFile, pos);
150777
- ts.Debug.assert(token.kind === 108 /* ThisKeyword */);
150850
+ if (!ts.isThis(token))
150851
+ return undefined;
150778
150852
  var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false);
150779
150853
  if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
150780
150854
  return undefined;
@@ -152584,6 +152658,9 @@ var ts;
152584
152658
  codefix.registerCodeFix({
152585
152659
  errorCodes: errorCodes,
152586
152660
  getCodeActions: function (context) {
152661
+ var syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
152662
+ if (syntacticDiagnostics.length)
152663
+ return;
152587
152664
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, context.span.start, context.span.length, context.errorCode); });
152588
152665
  return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Remove_unreachable_code, fixId, ts.Diagnostics.Remove_all_unreachable_code)];
152589
152666
  },
@@ -161219,6 +161296,7 @@ var ts;
161219
161296
  ], false);
161220
161297
  function createLanguageService(host, documentRegistry, syntaxOnlyOrLanguageServiceMode) {
161221
161298
  var _a;
161299
+ var _b;
161222
161300
  if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); }
161223
161301
  var languageServiceMode;
161224
161302
  if (syntaxOnlyOrLanguageServiceMode === undefined) {
@@ -161239,10 +161317,8 @@ var ts;
161239
161317
  ? new CancellationTokenObject(host.getCancellationToken())
161240
161318
  : NoopCancellationToken;
161241
161319
  var currentDirectory = host.getCurrentDirectory();
161242
- // Check if the localized messages json is set, otherwise query the host for it
161243
- if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
161244
- ts.setLocalizedDiagnosticMessages(host.getLocalizedDiagnosticMessages());
161245
- }
161320
+ // Checks if the localized messages json is set, and if not, query the host for it
161321
+ ts.maybeSetLocalizedDiagnosticMessages((_b = host.getLocalizedDiagnosticMessages) === null || _b === void 0 ? void 0 : _b.bind(host));
161246
161322
  function log(message) {
161247
161323
  if (host.log) {
161248
161324
  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;