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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220117";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220121";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -6799,11 +6799,15 @@ var ts;
6799
6799
  ts.getFileWatcherEventKind = getFileWatcherEventKind;
6800
6800
  /*@internal*/
6801
6801
  ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
6802
+ var curSysLog = ts.noop; // eslint-disable-line prefer-const
6802
6803
  /*@internal*/
6803
- ts.sysLog = ts.noop; // eslint-disable-line prefer-const
6804
+ function sysLog(s) {
6805
+ return curSysLog(s);
6806
+ }
6807
+ ts.sysLog = sysLog;
6804
6808
  /*@internal*/
6805
6809
  function setSysLog(logger) {
6806
- ts.sysLog = logger;
6810
+ curSysLog = logger;
6807
6811
  }
6808
6812
  ts.setSysLog = setSysLog;
6809
6813
  /**
@@ -6938,7 +6942,7 @@ var ts;
6938
6942
  }
6939
6943
  function onTimerToUpdateChildWatches() {
6940
6944
  timerToUpdateChildWatches = undefined;
6941
- ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
6945
+ sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
6942
6946
  var start = ts.timestamp();
6943
6947
  var invokeMap = new ts.Map();
6944
6948
  while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
@@ -6951,7 +6955,7 @@ var ts;
6951
6955
  var hasChanges = updateChildWatches(dirName, dirPath, options);
6952
6956
  invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
6953
6957
  }
6954
- ts.sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
6958
+ sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
6955
6959
  callbackCache.forEach(function (callbacks, rootDirName) {
6956
6960
  var existing = invokeMap.get(rootDirName);
6957
6961
  if (existing) {
@@ -6967,7 +6971,7 @@ var ts;
6967
6971
  }
6968
6972
  });
6969
6973
  var elapsed = ts.timestamp() - start;
6970
- ts.sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
6974
+ sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
6971
6975
  }
6972
6976
  function removeChildWatches(parentWatcher) {
6973
6977
  if (!parentWatcher)
@@ -7554,7 +7558,7 @@ var ts;
7554
7558
  * @param createWatcher
7555
7559
  */
7556
7560
  function invokeCallbackAndUpdateWatcher(createWatcher) {
7557
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7561
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7558
7562
  // Call the callback for current directory
7559
7563
  callback("rename", "");
7560
7564
  // If watcher is not closed, update it
@@ -7579,7 +7583,7 @@ var ts;
7579
7583
  }
7580
7584
  }
7581
7585
  if (hitSystemWatcherLimit) {
7582
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7586
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7583
7587
  return watchPresentFileSystemEntryWithFsWatchFile();
7584
7588
  }
7585
7589
  try {
@@ -7595,7 +7599,7 @@ var ts;
7595
7599
  // 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
7596
7600
  // so instead of throwing error, use fs.watchFile
7597
7601
  hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7598
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7602
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7599
7603
  return watchPresentFileSystemEntryWithFsWatchFile();
7600
7604
  }
7601
7605
  }
@@ -8194,6 +8198,7 @@ var ts;
8194
8198
  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"),
8195
8199
  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."),
8196
8200
  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."),
8201
+ catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8197
8202
  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."),
8198
8203
  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."),
8199
8204
  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),
@@ -8681,6 +8686,7 @@ var ts;
8681
8686
  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."),
8682
8687
  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}'?"),
8683
8688
  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."),
8689
+ 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."),
8684
8690
  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}'."),
8685
8691
  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}'."),
8686
8692
  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}'."),
@@ -9074,7 +9080,7 @@ var ts;
9074
9080
  Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
9075
9081
  _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"),
9076
9082
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
9077
- Found_0_errors_in_1_file: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_file_6260", "Found {0} errors in 1 file."),
9083
+ 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}"),
9078
9084
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
9079
9085
  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."),
9080
9086
  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}'."),
@@ -15847,7 +15853,7 @@ var ts;
15847
15853
  }
15848
15854
  ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
15849
15855
  function getExternalModuleRequireArgument(node) {
15850
- return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
15856
+ return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
15851
15857
  }
15852
15858
  ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
15853
15859
  function isInternalModuleImportEqualsDeclaration(node) {
@@ -15905,17 +15911,29 @@ var ts;
15905
15911
  * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`).
15906
15912
  * This function does not test if the node is in a JavaScript file or not.
15907
15913
  */
15908
- function isRequireVariableDeclaration(node) {
15914
+ function isVariableDeclarationInitializedToRequire(node) {
15915
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false);
15916
+ }
15917
+ ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
15918
+ /**
15919
+ * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`.
15920
+ */
15921
+ function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
15922
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true);
15923
+ }
15924
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
15925
+ function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
15909
15926
  if (node.kind === 202 /* BindingElement */) {
15910
15927
  node = node.parent.parent;
15911
15928
  }
15912
- return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true);
15929
+ return ts.isVariableDeclaration(node) &&
15930
+ !!node.initializer &&
15931
+ isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
15913
15932
  }
15914
- ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
15915
15933
  function isRequireVariableStatement(node) {
15916
15934
  return ts.isVariableStatement(node)
15917
15935
  && node.declarationList.declarations.length > 0
15918
- && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); });
15936
+ && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
15919
15937
  }
15920
15938
  ts.isRequireVariableStatement = isRequireVariableStatement;
15921
15939
  function isSingleOrDoubleQuote(charCode) {
@@ -19402,7 +19420,7 @@ var ts;
19402
19420
  getSourceMapSourceConstructor: function () { return SourceMapSource; },
19403
19421
  };
19404
19422
  function setObjectAllocator(alloc) {
19405
- ts.objectAllocator = alloc;
19423
+ Object.assign(ts.objectAllocator, alloc);
19406
19424
  }
19407
19425
  ts.setObjectAllocator = setObjectAllocator;
19408
19426
  function formatStringFromArgs(text, args, baseIndex) {
@@ -19410,13 +19428,22 @@ var ts;
19410
19428
  return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
19411
19429
  }
19412
19430
  ts.formatStringFromArgs = formatStringFromArgs;
19431
+ var localizedDiagnosticMessages;
19413
19432
  /* @internal */
19414
19433
  function setLocalizedDiagnosticMessages(messages) {
19415
- ts.localizedDiagnosticMessages = messages;
19434
+ localizedDiagnosticMessages = messages;
19416
19435
  }
19417
19436
  ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
19437
+ /* @internal */
19438
+ // If the localized messages json is unset, and if given function use it to set the json
19439
+ function maybeSetLocalizedDiagnosticMessages(getMessages) {
19440
+ if (!localizedDiagnosticMessages && getMessages) {
19441
+ localizedDiagnosticMessages = getMessages();
19442
+ }
19443
+ }
19444
+ ts.maybeSetLocalizedDiagnosticMessages = maybeSetLocalizedDiagnosticMessages;
19418
19445
  function getLocaleSpecificMessage(message) {
19419
- return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
19446
+ return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
19420
19447
  }
19421
19448
  ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
19422
19449
  function createDetachedDiagnostic(fileName, start, length, message) {
@@ -35025,7 +35052,7 @@ var ts;
35025
35052
  // one out no matter what.
35026
35053
  var finallyBlock;
35027
35054
  if (!catchClause || token() === 96 /* FinallyKeyword */) {
35028
- parseExpected(96 /* FinallyKeyword */);
35055
+ parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
35029
35056
  finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
35030
35057
  }
35031
35058
  return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
@@ -36069,7 +36096,7 @@ var ts;
36069
36096
  var pos = getNodePos();
36070
36097
  var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
36071
36098
  parseExpected(58 /* ColonToken */);
36072
- var value = parseLiteralLikeNode(10 /* StringLiteral */);
36099
+ var value = parseAssignmentExpressionOrHigher();
36073
36100
  return finishNode(factory.createAssertEntry(name, value), pos);
36074
36101
  }
36075
36102
  function parseAssertClause() {
@@ -44486,7 +44513,7 @@ var ts;
44486
44513
  maybeBindExpressionFlowIfCall(node.expression);
44487
44514
  }
44488
44515
  function maybeBindExpressionFlowIfCall(node) {
44489
- // A top level or LHS of comma expression call expression with a dotted function name and at least one argument
44516
+ // A top level or comma expression call expression with a dotted function name and at least one argument
44490
44517
  // is potentially an assertion and is therefore included in the control flow.
44491
44518
  if (node.kind === 207 /* CallExpression */) {
44492
44519
  var call = node;
@@ -44654,22 +44681,27 @@ var ts;
44654
44681
  }
44655
44682
  return state;
44656
44683
  }
44657
- function onLeft(left, state, _node) {
44684
+ function onLeft(left, state, node) {
44658
44685
  if (!state.skip) {
44659
- return maybeBind(left);
44686
+ var maybeBound = maybeBind(left);
44687
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44688
+ maybeBindExpressionFlowIfCall(left);
44689
+ }
44690
+ return maybeBound;
44660
44691
  }
44661
44692
  }
44662
- function onOperator(operatorToken, state, node) {
44693
+ function onOperator(operatorToken, state, _node) {
44663
44694
  if (!state.skip) {
44664
- if (operatorToken.kind === 27 /* CommaToken */) {
44665
- maybeBindExpressionFlowIfCall(node.left);
44666
- }
44667
44695
  bind(operatorToken);
44668
44696
  }
44669
44697
  }
44670
- function onRight(right, state, _node) {
44698
+ function onRight(right, state, node) {
44671
44699
  if (!state.skip) {
44672
- return maybeBind(right);
44700
+ var maybeBound = maybeBind(right);
44701
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44702
+ maybeBindExpressionFlowIfCall(right);
44703
+ }
44704
+ return maybeBound;
44673
44705
  }
44674
44706
  }
44675
44707
  function onExit(node, state) {
@@ -45412,6 +45444,8 @@ var ts;
45412
45444
  return;
45413
45445
  }
45414
45446
  ts.setParent(node, parent);
45447
+ if (ts.tracing)
45448
+ node.tracingPath = file.path;
45415
45449
  var saveInStrictMode = inStrictMode;
45416
45450
  // Even though in the AST the jsdoc @typedef node belongs to the current node,
45417
45451
  // its symbol might be in the same scope with the current node's symbol. Consider:
@@ -46232,7 +46266,7 @@ var ts;
46232
46266
  checkStrictModeEvalOrArguments(node, node.name);
46233
46267
  }
46234
46268
  if (!ts.isBindingPattern(node.name)) {
46235
- if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) {
46269
+ if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
46236
46270
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
46237
46271
  }
46238
46272
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -49015,7 +49049,7 @@ var ts;
49015
49049
  && isAliasableOrJsExpression(node.parent.right)
49016
49050
  || node.kind === 295 /* ShorthandPropertyAssignment */
49017
49051
  || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
49018
- || ts.isRequireVariableDeclaration(node);
49052
+ || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
49019
49053
  }
49020
49054
  function isAliasableOrJsExpression(e) {
49021
49055
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -49803,8 +49837,14 @@ var ts;
49803
49837
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49804
49838
  var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
49805
49839
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49806
- var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
49840
+ var sourceFile = resolvedModule
49841
+ && (!resolutionDiagnostic || resolutionDiagnostic === ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set)
49842
+ && host.getSourceFile(resolvedModule.resolvedFileName);
49807
49843
  if (sourceFile) {
49844
+ // If there's a resolutionDiagnostic we need to report it even if a sourceFile is found.
49845
+ if (resolutionDiagnostic) {
49846
+ error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
49847
+ }
49808
49848
  if (sourceFile.symbol) {
49809
49849
  if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
49810
49850
  errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
@@ -50946,6 +50986,7 @@ var ts;
50946
50986
  getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
50947
50987
  getCurrentDirectory: function () { return host.getCurrentDirectory(); },
50948
50988
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
50989
+ getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
50949
50990
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
50950
50991
  redirectTargetsMap: host.redirectTargetsMap,
50951
50992
  getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
@@ -77892,7 +77933,7 @@ var ts;
77892
77933
  }
77893
77934
  }
77894
77935
  function checkExpression(node, checkMode, forceTuple) {
77895
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
77936
+ 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 });
77896
77937
  var saveCurrentNode = currentNode;
77897
77938
  currentNode = node;
77898
77939
  instantiationCount = 0;
@@ -80573,7 +80614,7 @@ var ts;
80573
80614
  }
80574
80615
  // For a commonjs `const x = require`, validate the alias and exit
80575
80616
  var symbol = getSymbolOfNode(node);
80576
- if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) {
80617
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
80577
80618
  checkAliasSymbol(node);
80578
80619
  return;
80579
80620
  }
@@ -80651,7 +80692,7 @@ var ts;
80651
80692
  return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
80652
80693
  }
80653
80694
  function checkVariableDeclaration(node) {
80654
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
80695
+ 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 });
80655
80696
  checkGrammarVariableDeclaration(node);
80656
80697
  checkVariableLikeDeclaration(node);
80657
80698
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -83041,6 +83082,17 @@ var ts;
83041
83082
  return false;
83042
83083
  }
83043
83084
  }
83085
+ if (!ts.isImportEqualsDeclaration(node) && node.assertClause) {
83086
+ var hasError = false;
83087
+ for (var _i = 0, _a = node.assertClause.elements; _i < _a.length; _i++) {
83088
+ var clause = _a[_i];
83089
+ if (!ts.isStringLiteral(clause.value)) {
83090
+ hasError = true;
83091
+ error(clause.value, ts.Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
83092
+ }
83093
+ }
83094
+ return !hasError;
83095
+ }
83044
83096
  return true;
83045
83097
  }
83046
83098
  function checkAliasSymbol(node) {
@@ -83734,7 +83786,7 @@ var ts;
83734
83786
  }
83735
83787
  }
83736
83788
  function checkDeferredNode(node) {
83737
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
83789
+ 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 });
83738
83790
  var saveCurrentNode = currentNode;
83739
83791
  currentNode = node;
83740
83792
  instantiationCount = 0;
@@ -87668,7 +87720,7 @@ var ts;
87668
87720
  return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine);
87669
87721
  case 293 /* AssertEntry */:
87670
87722
  ts.Debug.type(node);
87671
- return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isStringLiteral));
87723
+ return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode));
87672
87724
  case 266 /* ImportClause */:
87673
87725
  ts.Debug.type(node);
87674
87726
  return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
@@ -95518,10 +95570,19 @@ var ts;
95518
95570
  var _a;
95519
95571
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95520
95572
  var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95521
- var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95573
+ var args = [tagName, objectProperties];
95574
+ // function jsx(type, config, maybeKey) {}
95575
+ // "maybeKey" is optional. It is acceptable to use "_jsx" without a third argument
95576
+ if (keyAttr) {
95577
+ args.push(transformJsxAttributeInitializer(keyAttr.initializer));
95578
+ }
95522
95579
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95523
95580
  var originalFile = ts.getOriginalNode(currentSourceFile);
95524
95581
  if (originalFile && ts.isSourceFile(originalFile)) {
95582
+ // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
95583
+ if (keyAttr === undefined) {
95584
+ args.push(factory.createVoidZero());
95585
+ }
95525
95586
  // isStaticChildren development flag
95526
95587
  args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95527
95588
  // __source development flag
@@ -119386,11 +119447,12 @@ var ts;
119386
119447
  };
119387
119448
  }
119388
119449
  function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
119450
+ var _a;
119389
119451
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
119390
119452
  && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
119391
119453
  return false;
119392
119454
  }
119393
- return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119455
+ return ts.getImpliedNodeFormatForFile(importingSourceFileName, (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host), getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119394
119456
  }
119395
119457
  function getModuleResolutionHost(host) {
119396
119458
  var _a;
@@ -119950,11 +120012,13 @@ var ts;
119950
120012
  // For classic resolution, only allow importing from node_modules/@types, not other node_modules
119951
120013
  return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
119952
120014
  function tryDirectoryWithPackageJson(packageRootIndex) {
120015
+ var _a, _b;
119953
120016
  var packageRootPath = path.substring(0, packageRootIndex);
119954
120017
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
119955
120018
  var moduleFileToTry = path;
119956
- if (host.fileExists(packageJsonPath)) {
119957
- var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
120019
+ var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
120020
+ if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
120021
+ var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
119958
120022
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119959
120023
  // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
119960
120024
  // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
@@ -120254,22 +120318,31 @@ var ts;
120254
120318
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
120255
120319
  }
120256
120320
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
120321
+ function prettyPathForFileError(error, cwd) {
120322
+ var line = ts.formatColorAndReset(":" + error.line, ts.ForegroundColorEscapeSequences.Grey);
120323
+ if (ts.pathIsAbsolute(error.fileName) && ts.pathIsAbsolute(cwd)) {
120324
+ return ts.getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
120325
+ }
120326
+ return error.fileName + line;
120327
+ }
120257
120328
  function getErrorSummaryText(errorCount, filesInError, newLine, host) {
120258
120329
  if (errorCount === 0)
120259
120330
  return "";
120260
120331
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
120261
120332
  var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; })
120262
120333
  .filter(function (value, index, self) { return self.indexOf(value) === index; });
120334
+ var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory());
120263
120335
  var d = errorCount === 1 ?
120264
120336
  ts.createCompilerDiagnostic(filesInError[0] !== undefined ?
120265
120337
  ts.Diagnostics.Found_1_error_in_1 :
120266
- ts.Diagnostics.Found_1_error, errorCount, distinctFileNamesWithLines[0]) :
120338
+ ts.Diagnostics.Found_1_error, errorCount, firstFileReference) :
120267
120339
  ts.createCompilerDiagnostic(distinctFileNamesWithLines.length === 0 ?
120268
120340
  ts.Diagnostics.Found_0_errors :
120269
120341
  distinctFileNamesWithLines.length === 1 ?
120270
- ts.Diagnostics.Found_0_errors_in_1_file :
120271
- ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
120272
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
120342
+ ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 :
120343
+ ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length);
120344
+ var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "";
120345
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix;
120273
120346
  }
120274
120347
  ts.getErrorSummaryText = getErrorSummaryText;
120275
120348
  function createTabularErrorsDisplay(filesInError, host) {
@@ -120291,8 +120364,8 @@ var ts;
120291
120364
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
120292
120365
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
120293
120366
  : "";
120294
- var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
120295
- tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
120367
+ var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
120368
+ tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n";
120296
120369
  });
120297
120370
  return tabularData;
120298
120371
  }
@@ -120793,6 +120866,7 @@ var ts;
120793
120866
  var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
120794
120867
  var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
120795
120868
  var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
120869
+ var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
120796
120870
  var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
120797
120871
  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
120798
120872
  var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
@@ -120955,14 +121029,21 @@ var ts;
120955
121029
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
120956
121030
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
120957
121031
  if (hasChangedConfigFileParsingErrors) {
121032
+ if (reportFileChangeDetectedOnCreateProgram) {
121033
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121034
+ }
120958
121035
  builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
120959
121036
  hasChangedConfigFileParsingErrors = false;
120960
121037
  }
120961
121038
  }
120962
121039
  else {
121040
+ if (reportFileChangeDetectedOnCreateProgram) {
121041
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121042
+ }
120963
121043
  createNewProgram(hasInvalidatedResolution);
120964
121044
  }
120965
121045
  changesAffectResolution = false; // reset for next sync
121046
+ reportFileChangeDetectedOnCreateProgram = false;
120966
121047
  if (host.afterProgramCreate && program !== builderProgram) {
120967
121048
  host.afterProgramCreate(builderProgram);
120968
121049
  }
@@ -121164,7 +121245,7 @@ var ts;
121164
121245
  }
121165
121246
  function updateProgramWithWatchStatus() {
121166
121247
  timerToUpdateProgram = undefined;
121167
- reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121248
+ reportFileChangeDetectedOnCreateProgram = true;
121168
121249
  updateProgram();
121169
121250
  }
121170
121251
  function updateProgram() {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.6.0-dev.20220117",
5
+ "version": "4.6.0-dev.20220121",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -93,7 +93,7 @@
93
93
  "q": "latest",
94
94
  "source-map-support": "latest",
95
95
  "through2": "latest",
96
- "typescript": "^4.2.3",
96
+ "typescript": "^4.5.5",
97
97
  "vinyl": "latest",
98
98
  "vinyl-sourcemaps-apply": "latest",
99
99
  "xml2js": "^0.4.19"