typescript 4.7.0-dev.20220330 → 4.7.0-dev.20220402

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.20220330";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220402";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -9484,6 +9484,7 @@ var ts;
9484
9484
  An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, ts.DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"),
9485
9485
  Compiles_the_current_project_with_additional_settings: diag(6929, ts.DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."),
9486
9486
  true_for_ES2022_and_above_including_ESNext: diag(6930, ts.DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."),
9487
+ List_of_file_name_suffixes_to_search_when_resolving_a_module: diag(6931, ts.DiagnosticCategory.Error, "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931", "List of file name suffixes to search when resolving a module."),
9487
9488
  Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
9488
9489
  Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
9489
9490
  Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
@@ -39478,6 +39479,18 @@ var ts;
39478
39479
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39479
39480
  defaultValueDescription: false,
39480
39481
  },
39482
+ {
39483
+ name: "moduleSuffixes",
39484
+ type: "list",
39485
+ element: {
39486
+ name: "suffix",
39487
+ type: "string",
39488
+ },
39489
+ listPreserveFalsyValues: true,
39490
+ affectsModuleResolution: true,
39491
+ category: ts.Diagnostics.Modules,
39492
+ description: ts.Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module,
39493
+ },
39481
39494
  // Source Maps
39482
39495
  {
39483
39496
  name: "sourceRoot",
@@ -41404,7 +41417,7 @@ var ts;
41404
41417
  if (option.type === "list") {
41405
41418
  var listOption_1 = option;
41406
41419
  if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
41407
- return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
41420
+ return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return listOption_1.listPreserveFalsyValues ? true : !!v; });
41408
41421
  }
41409
41422
  return value;
41410
41423
  }
@@ -41445,7 +41458,7 @@ var ts;
41445
41458
  }
41446
41459
  }
41447
41460
  function convertJsonOptionOfListType(option, values, basePath, errors) {
41448
- return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
41461
+ return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return option.listPreserveFalsyValues ? true : !!v; });
41449
41462
  }
41450
41463
  /**
41451
41464
  * Tests for a path that ends in a recursive directory wildcard.
@@ -43071,6 +43084,15 @@ var ts;
43071
43084
  }
43072
43085
  /** Return the file if it exists. */
43073
43086
  function tryFile(fileName, onlyRecordFailures, state) {
43087
+ var _a, _b;
43088
+ if (!((_a = state.compilerOptions.moduleSuffixes) === null || _a === void 0 ? void 0 : _a.length)) {
43089
+ return tryFileLookup(fileName, onlyRecordFailures, state);
43090
+ }
43091
+ var ext = (_b = ts.tryGetExtensionFromPath(fileName)) !== null && _b !== void 0 ? _b : "";
43092
+ var fileNameNoExtension = ext ? ts.removeExtension(fileName, ext) : fileName;
43093
+ return ts.forEach(state.compilerOptions.moduleSuffixes, function (suffix) { return tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state); });
43094
+ }
43095
+ function tryFileLookup(fileName, onlyRecordFailures, state) {
43074
43096
  if (!onlyRecordFailures) {
43075
43097
  if (state.host.fileExists(fileName)) {
43076
43098
  if (state.traceEnabled) {
@@ -52066,7 +52088,15 @@ var ts;
52066
52088
  if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) {
52067
52089
  return node;
52068
52090
  }
52069
- return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node);
52091
+ return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext, deepCloneOrReuseNodes)), node);
52092
+ }
52093
+ function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
52094
+ if (nodes && nodes.length === 0) {
52095
+ // Ensure we explicitly make a copy of an empty array; visitNodes will not do this unless the array has elements,
52096
+ // which can lead to us reusing the same empty NodeArray more than once within the same AST during type noding.
52097
+ return ts.setTextRange(ts.factory.createNodeArray(/*nodes*/ undefined, nodes.hasTrailingComma), nodes);
52098
+ }
52099
+ return ts.visitNodes(nodes, visitor, test, start, count);
52070
52100
  }
52071
52101
  }
52072
52102
  function createTypeNodeFromObjectType(type) {
@@ -70796,7 +70826,7 @@ var ts;
70796
70826
  if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
70797
70827
  var contextualSignature = getContextualSignature(func);
70798
70828
  if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
70799
- var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
70829
+ var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0]));
70800
70830
  if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
70801
70831
  var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
70802
70832
  var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
@@ -72101,9 +72131,14 @@ var ts;
72101
72131
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
72102
72132
  }
72103
72133
  // For other purposes (e.g. determining whether to produce literal types) we only
72104
- // incorporate inferences made from the return type in a function call.
72134
+ // incorporate inferences made from the return type in a function call. We remove
72135
+ // the 'boolean' type from the contextual type such that contextually typed boolean
72136
+ // literals actually end up widening to 'boolean' (see #48363).
72105
72137
  if (inferenceContext.returnMapper) {
72106
- return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72138
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72139
+ return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
72140
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
72141
+ type;
72107
72142
  }
72108
72143
  }
72109
72144
  }
@@ -111112,6 +111147,7 @@ var ts;
111112
111147
  writeLine();
111113
111148
  decreaseIndent();
111114
111149
  }
111150
+ emitList(node, node.members, 2 /* PreserveLines */);
111115
111151
  writePunctuation("}");
111116
111152
  }
111117
111153
  function emitLiteralType(node) {
@@ -879,6 +879,7 @@
879
879
  "Library_referenced_via_0_from_file_1_1405": "通过 \"{0}\" 从文件 \"{1}\" 引用了库",
880
880
  "Line_break_not_permitted_here_1142": "不允许在此处换行。",
881
881
  "Line_terminator_not_permitted_before_arrow_1200": "箭头前不允许有行终止符。",
882
+ "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931": "解析模块时要搜索的文件名后缀列表。",
882
883
  "List_of_folders_to_include_type_definitions_from_6161": "包含类型定义来源的文件夹列表。",
883
884
  "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168": "根文件夹列表,其组合内容表示在运行时的项目结构。",
884
885
  "Loading_0_from_the_root_dir_1_candidate_location_2_6109": "正在从根目录“{1}”加载“{0}”,候选位置“{2}”。",
@@ -879,6 +879,7 @@
879
879
  "Library_referenced_via_0_from_file_1_1405": "透過 '{0}' 從檔案 '{1}' 參考的程式庫",
880
880
  "Line_break_not_permitted_here_1142": "這裡不可使用分行符號。",
881
881
  "Line_terminator_not_permitted_before_arrow_1200": "箭號前不得有行結束字元。",
882
+ "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931": "解析模組時要搜尋的檔案名尾碼清單。",
882
883
  "List_of_folders_to_include_type_definitions_from_6161": "要包含之類型定義所屬資料夾的清單。",
883
884
  "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168": "資料夾的清單。這些資料夾內所含的合併內容代表了專案在執行階段時的結果。",
884
885
  "Loading_0_from_the_root_dir_1_candidate_location_2_6109": "正在從根目錄 '{1}',候選位置 '{2}' 載入 '{0}'。",
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.7.0-dev.20220330",
5
+ "version": "4.7.0-dev.20220402",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [