typescript 4.7.0-dev.20220217 → 4.7.0-dev.20220218

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.20220217";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220218";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -2412,7 +2412,7 @@ var ts;
2412
2412
  Debug.checkEachDefined = checkEachDefined;
2413
2413
  function assertNever(member, message, stackCrawlMark) {
2414
2414
  if (message === void 0) { message = "Illegal value:"; }
2415
- var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
2415
+ var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
2416
2416
  return fail(message + " " + detail, stackCrawlMark || assertNever);
2417
2417
  }
2418
2418
  Debug.assertNever = assertNever;
@@ -62984,10 +62984,6 @@ var ts;
62984
62984
  if (sourceRestType || targetRestType) {
62985
62985
  void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
62986
62986
  }
62987
- if (sourceRestType && targetRestType && sourceCount !== targetCount) {
62988
- // We're not able to relate misaligned complex rest parameters
62989
- return 0 /* False */;
62990
- }
62991
62987
  var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
62992
62988
  var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
62993
62989
  kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
@@ -77366,7 +77362,7 @@ var ts;
77366
77362
  if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
77367
77363
  if (operator === 55 /* AmpersandAmpersandToken */) {
77368
77364
  var parent = ts.walkUpParenthesizedExpressions(node.parent);
77369
- checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
77365
+ checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
77370
77366
  }
77371
77367
  checkTruthinessOfType(leftType, node.left);
77372
77368
  }
@@ -77873,8 +77869,8 @@ var ts;
77873
77869
  return type;
77874
77870
  }
77875
77871
  function checkConditionalExpression(node, checkMode) {
77876
- var type = checkTruthinessExpression(node.condition);
77877
- checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
77872
+ checkTruthinessExpression(node.condition);
77873
+ checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
77878
77874
  var type1 = checkExpression(node.whenTrue, checkMode);
77879
77875
  var type2 = checkExpression(node.whenFalse, checkMode);
77880
77876
  return getUnionType([type1, type2], 2 /* Subtype */);
@@ -81030,50 +81026,59 @@ var ts;
81030
81026
  function checkIfStatement(node) {
81031
81027
  // Grammar checking
81032
81028
  checkGrammarStatementInAmbientContext(node);
81033
- var type = checkTruthinessExpression(node.expression);
81034
- checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement);
81029
+ checkTruthinessExpression(node.expression);
81030
+ checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
81035
81031
  checkSourceElement(node.thenStatement);
81036
81032
  if (node.thenStatement.kind === 235 /* EmptyStatement */) {
81037
81033
  error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
81038
81034
  }
81039
81035
  checkSourceElement(node.elseStatement);
81040
81036
  }
81041
- function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) {
81037
+ function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
81042
81038
  if (!strictNullChecks)
81043
81039
  return;
81044
- if (getFalsyFlags(type))
81045
- return;
81046
- var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr;
81047
- if (ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression)) {
81048
- return;
81049
- }
81050
- var testedNode = ts.isIdentifier(location) ? location
81051
- : ts.isPropertyAccessExpression(location) ? location.name
81052
- : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
81053
- : undefined;
81054
- // While it technically should be invalid for any known-truthy value
81055
- // to be tested, we de-scope to functions and Promises unreferenced in
81056
- // the block as a heuristic to identify the most common bugs. There
81057
- // are too many false positives for values sourced from type
81058
- // definitions without strictNullChecks otherwise.
81059
- var callSignatures = getSignaturesOfType(type, 0 /* Call */);
81060
- var isPromise = !!getAwaitedTypeOfPromise(type);
81061
- if (callSignatures.length === 0 && !isPromise) {
81062
- return;
81063
- }
81064
- var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
81065
- if (!testedSymbol && !isPromise) {
81066
- return;
81067
- }
81068
- var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
81069
- || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
81070
- if (!isUsed) {
81071
- if (isPromise) {
81072
- errorAndMaybeSuggestAwait(location,
81073
- /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
81040
+ helper(condExpr, body);
81041
+ while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) {
81042
+ condExpr = condExpr.left;
81043
+ helper(condExpr, body);
81044
+ }
81045
+ function helper(condExpr, body) {
81046
+ var location = ts.isBinaryExpression(condExpr) &&
81047
+ (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
81048
+ ? condExpr.right
81049
+ : condExpr;
81050
+ var type = checkTruthinessExpression(location);
81051
+ var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
81052
+ if (getFalsyFlags(type) || isPropertyExpressionCast)
81053
+ return;
81054
+ // While it technically should be invalid for any known-truthy value
81055
+ // to be tested, we de-scope to functions and Promises unreferenced in
81056
+ // the block as a heuristic to identify the most common bugs. There
81057
+ // are too many false positives for values sourced from type
81058
+ // definitions without strictNullChecks otherwise.
81059
+ var callSignatures = getSignaturesOfType(type, 0 /* Call */);
81060
+ var isPromise = !!getAwaitedTypeOfPromise(type);
81061
+ if (callSignatures.length === 0 && !isPromise) {
81062
+ return;
81074
81063
  }
81075
- else {
81076
- error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
81064
+ var testedNode = ts.isIdentifier(location) ? location
81065
+ : ts.isPropertyAccessExpression(location) ? location.name
81066
+ : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
81067
+ : undefined;
81068
+ var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
81069
+ if (!testedSymbol && !isPromise) {
81070
+ return;
81071
+ }
81072
+ var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
81073
+ || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
81074
+ if (!isUsed) {
81075
+ if (isPromise) {
81076
+ errorAndMaybeSuggestAwait(location,
81077
+ /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
81078
+ }
81079
+ else {
81080
+ error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
81081
+ }
81077
81082
  }
81078
81083
  }
81079
81084
  }
@@ -83867,10 +83872,10 @@ var ts;
83867
83872
  }
83868
83873
  // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
83869
83874
  // (TS Exceptions: namespaces, function overloads, enums, and interfaces)
83870
- if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) {
83875
+ if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
83871
83876
  return;
83872
83877
  }
83873
- var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
83878
+ var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
83874
83879
  if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
83875
83880
  // it is legal to merge type alias with other values
83876
83881
  // so count should be either 1 (just type alias) or 2 (type alias + merged value)
@@ -491,6 +491,8 @@
491
491
  "Declare_property_0_90016": "声明属性“{0}”",
492
492
  "Declare_static_method_0_90024": "声明静态方法“{0}”",
493
493
  "Declare_static_property_0_90027": "声明静态属性“{0}”",
494
+ "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270": "装饰器函数返回类型“{0}”不可分配到类型“{1}”。",
495
+ "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271": "装饰器函数返回类型为“{0}”,但预期为“void”或“any”。",
494
496
  "Decorators_are_not_valid_here_1206": "修饰器在此处无效。",
495
497
  "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207": "不能向多个同名的 get/set 访问器应用修饰器。",
496
498
  "Decorators_may_not_be_applied_to_this_parameters_1433": "修饰器不能应用于 “this” 参数。",
@@ -1197,6 +1199,7 @@
1197
1199
  "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "所需的类型参数可能不遵循可选类型参数。",
1198
1200
  "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "在位置“{1}”的缓存中找到模块“{0}”的解析。",
1199
1201
  "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241": "在位置“{1}”的缓存中找到类型引用指令“{0}”的解析。",
1202
+ "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452": "仅当“moduleResolution”为“node12”或“nodenext”时才支持解析模式。",
1200
1203
  "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "只将 \"keyof\" 解析为字符串值的属性名称(不含数字或符号)。",
1201
1204
  "Resolving_module_0_from_1_6086": "======== 正在从“{1}”解析模块“{0}”。========",
1202
1205
  "Resolving_module_name_0_relative_to_base_url_1_2_6094": "正在相对于基 URL“{1}”-“{2}”解析模块名“{0}”。",
@@ -1778,6 +1781,7 @@
1778
1781
  "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024": "\"readonly\" 修饰符仅可出现在属性声明或索引签名中。",
1779
1782
  "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354": "仅允许对数组和元组文本类型使用 \"readonly\" 类型修饰符。",
1780
1783
  "require_call_may_be_converted_to_an_import_80005": "可将“要求”调用转换为导入。",
1784
+ "resolution_mode_should_be_either_require_or_import_1453": "“resolution-mode”应为“require”或“import”。",
1781
1785
  "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107": "设置了 \"rootDirs\" 选项,可将其用于解析相对模块名称“{0}”。",
1782
1786
  "super_can_only_be_referenced_in_a_derived_class_2335": "只能在派生类中引用 \"super\"。",
1783
1787
  "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660": "仅可在派生类或对象文字表达式的成员中引用 \"super\"。",
@@ -491,6 +491,8 @@
491
491
  "Declare_property_0_90016": "宣告屬性 '{0}'",
492
492
  "Declare_static_method_0_90024": "宣告靜態方法 '{0}'",
493
493
  "Declare_static_property_0_90027": "宣告靜態屬性 '{0}'",
494
+ "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270": "裝飾項目函式傳回類型 '{0}' 無法指派給類型 '{1}'。",
495
+ "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271": "裝飾項目函式傳回類型是 '{0}',但必須是 'void' 或 'any'。",
494
496
  "Decorators_are_not_valid_here_1206": "裝飾項目在此處無效。",
495
497
  "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207": "無法將裝飾項目套用至多個同名的 get/set 存取子。",
496
498
  "Decorators_may_not_be_applied_to_this_parameters_1433": "裝飾項目無法套用至 'this' 參數。",
@@ -1197,6 +1199,7 @@
1197
1199
  "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "必要型別參數可能未遵循選擇性型別參數。",
1198
1200
  "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "從位置 '{1}' 的快取中找到模組 '{0}' 的解析。",
1199
1201
  "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241": "從位置 '{0}' 的快取記憶體找到類型參照指示詞 '{1}'。",
1202
+ "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452": "只有當 'moduleResolution' 為 'node12' 或 'nodenext' 時,才支援解析模式。",
1200
1203
  "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "只將 'keyof' 解析為字串值的屬性名稱 (無任何數字或符號)。",
1201
1204
  "Resolving_module_0_from_1_6086": "======== 正在從 '{1}' 解析模組 '{0}'。========",
1202
1205
  "Resolving_module_name_0_relative_to_base_url_1_2_6094": "正在解析與基底 URL '{1}' 相對的模組名稱 '{0}' - '{2}'。",
@@ -1778,6 +1781,7 @@
1778
1781
  "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024": "'readonly' 修飾元只能出現在屬性宣告或索引簽章。",
1779
1782
  "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354": "'readonly' 類型修飾元只可用於陣列與元組常值類型。",
1780
1783
  "require_call_may_be_converted_to_an_import_80005": "'require' 呼叫可能會轉換為匯入。",
1784
+ "resolution_mode_should_be_either_require_or_import_1453": "`resolution-mode` 應該是 `require` 或 `import`。",
1781
1785
  "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107": "'rootDirs' 選項已設定。該選項將用於解析相對的模組名稱 '{0}'。",
1782
1786
  "super_can_only_be_referenced_in_a_derived_class_2335": "只有衍生類別中才可參考 'super'。",
1783
1787
  "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660": "只有在衍生類別或物件常值運算式的成員中才可參考 'super'。",
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.20220217",
5
+ "version": "4.7.0-dev.20220218",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [