typescript 4.7.0-dev.20220217 → 4.7.0-dev.20220221

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.
@@ -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.20220217";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220221";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2617,7 +2617,7 @@ var ts;
2617
2617
  Debug.checkEachDefined = checkEachDefined;
2618
2618
  function assertNever(member, message, stackCrawlMark) {
2619
2619
  if (message === void 0) { message = "Illegal value:"; }
2620
- var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
2620
+ var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
2621
2621
  return fail(message + " " + detail, stackCrawlMark || assertNever);
2622
2622
  }
2623
2623
  Debug.assertNever = assertNever;
@@ -9770,7 +9770,7 @@ var ts;
9770
9770
  Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
9771
9771
  Wrap_invalid_character_in_an_expression_container: diag(95108, ts.DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"),
9772
9772
  Wrap_all_invalid_characters_in_an_expression_container: diag(95109, ts.DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"),
9773
- Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig.json to read more about this file"),
9773
+ Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig to read more about this file"),
9774
9774
  Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
9775
9775
  Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
9776
9776
  Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, ts.DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"),
@@ -40657,7 +40657,7 @@ var ts;
40657
40657
  var result = [];
40658
40658
  result.push("{");
40659
40659
  result.push(tab + "\"compilerOptions\": {");
40660
- result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
40660
+ result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */");
40661
40661
  result.push("");
40662
40662
  // Print out each row, aligning all the descriptions on the same column.
40663
40663
  for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
@@ -63189,10 +63189,6 @@ var ts;
63189
63189
  if (sourceRestType || targetRestType) {
63190
63190
  void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
63191
63191
  }
63192
- if (sourceRestType && targetRestType && sourceCount !== targetCount) {
63193
- // We're not able to relate misaligned complex rest parameters
63194
- return 0 /* False */;
63195
- }
63196
63192
  var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
63197
63193
  var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
63198
63194
  kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
@@ -70250,7 +70246,7 @@ var ts;
70250
70246
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
70251
70247
  someType(type, isGenericTypeWithUnionConstraint) &&
70252
70248
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
70253
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
70249
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
70254
70250
  }
70255
70251
  function isExportOrExportExpression(location) {
70256
70252
  return !!ts.findAncestor(location, function (n) {
@@ -77571,7 +77567,7 @@ var ts;
77571
77567
  if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
77572
77568
  if (operator === 55 /* AmpersandAmpersandToken */) {
77573
77569
  var parent = ts.walkUpParenthesizedExpressions(node.parent);
77574
- checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
77570
+ checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
77575
77571
  }
77576
77572
  checkTruthinessOfType(leftType, node.left);
77577
77573
  }
@@ -78078,8 +78074,8 @@ var ts;
78078
78074
  return type;
78079
78075
  }
78080
78076
  function checkConditionalExpression(node, checkMode) {
78081
- var type = checkTruthinessExpression(node.condition);
78082
- checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
78077
+ checkTruthinessExpression(node.condition);
78078
+ checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
78083
78079
  var type1 = checkExpression(node.whenTrue, checkMode);
78084
78080
  var type2 = checkExpression(node.whenFalse, checkMode);
78085
78081
  return getUnionType([type1, type2], 2 /* Subtype */);
@@ -81235,50 +81231,59 @@ var ts;
81235
81231
  function checkIfStatement(node) {
81236
81232
  // Grammar checking
81237
81233
  checkGrammarStatementInAmbientContext(node);
81238
- var type = checkTruthinessExpression(node.expression);
81239
- checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement);
81234
+ checkTruthinessExpression(node.expression);
81235
+ checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
81240
81236
  checkSourceElement(node.thenStatement);
81241
81237
  if (node.thenStatement.kind === 235 /* EmptyStatement */) {
81242
81238
  error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
81243
81239
  }
81244
81240
  checkSourceElement(node.elseStatement);
81245
81241
  }
81246
- function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) {
81242
+ function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
81247
81243
  if (!strictNullChecks)
81248
81244
  return;
81249
- if (getFalsyFlags(type))
81250
- return;
81251
- var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr;
81252
- if (ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression)) {
81253
- return;
81254
- }
81255
- var testedNode = ts.isIdentifier(location) ? location
81256
- : ts.isPropertyAccessExpression(location) ? location.name
81257
- : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
81258
- : undefined;
81259
- // While it technically should be invalid for any known-truthy value
81260
- // to be tested, we de-scope to functions and Promises unreferenced in
81261
- // the block as a heuristic to identify the most common bugs. There
81262
- // are too many false positives for values sourced from type
81263
- // definitions without strictNullChecks otherwise.
81264
- var callSignatures = getSignaturesOfType(type, 0 /* Call */);
81265
- var isPromise = !!getAwaitedTypeOfPromise(type);
81266
- if (callSignatures.length === 0 && !isPromise) {
81267
- return;
81268
- }
81269
- var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
81270
- if (!testedSymbol && !isPromise) {
81271
- return;
81272
- }
81273
- var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
81274
- || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
81275
- if (!isUsed) {
81276
- if (isPromise) {
81277
- errorAndMaybeSuggestAwait(location,
81278
- /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
81245
+ helper(condExpr, body);
81246
+ while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) {
81247
+ condExpr = condExpr.left;
81248
+ helper(condExpr, body);
81249
+ }
81250
+ function helper(condExpr, body) {
81251
+ var location = ts.isBinaryExpression(condExpr) &&
81252
+ (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
81253
+ ? condExpr.right
81254
+ : condExpr;
81255
+ var type = checkTruthinessExpression(location);
81256
+ var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
81257
+ if (getFalsyFlags(type) || isPropertyExpressionCast)
81258
+ return;
81259
+ // While it technically should be invalid for any known-truthy value
81260
+ // to be tested, we de-scope to functions and Promises unreferenced in
81261
+ // the block as a heuristic to identify the most common bugs. There
81262
+ // are too many false positives for values sourced from type
81263
+ // definitions without strictNullChecks otherwise.
81264
+ var callSignatures = getSignaturesOfType(type, 0 /* Call */);
81265
+ var isPromise = !!getAwaitedTypeOfPromise(type);
81266
+ if (callSignatures.length === 0 && !isPromise) {
81267
+ return;
81279
81268
  }
81280
- else {
81281
- error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
81269
+ var testedNode = ts.isIdentifier(location) ? location
81270
+ : ts.isPropertyAccessExpression(location) ? location.name
81271
+ : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
81272
+ : undefined;
81273
+ var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
81274
+ if (!testedSymbol && !isPromise) {
81275
+ return;
81276
+ }
81277
+ var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
81278
+ || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
81279
+ if (!isUsed) {
81280
+ if (isPromise) {
81281
+ errorAndMaybeSuggestAwait(location,
81282
+ /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
81283
+ }
81284
+ else {
81285
+ error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
81286
+ }
81282
81287
  }
81283
81288
  }
81284
81289
  }
@@ -82467,9 +82472,9 @@ var ts;
82467
82472
  var containsArguments = containsArgumentsReference(node);
82468
82473
  if (containsArguments) {
82469
82474
  var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
82470
- if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82475
+ if (isJs && lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82471
82476
  lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
82472
- errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
82477
+ error(lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
82473
82478
  }
82474
82479
  }
82475
82480
  else {
@@ -82479,7 +82484,9 @@ var ts;
82479
82484
  return;
82480
82485
  }
82481
82486
  if (ts.isQualifiedName(name)) {
82482
- errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82487
+ if (isJs) {
82488
+ error(name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82489
+ }
82483
82490
  }
82484
82491
  else {
82485
82492
  errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
@@ -84072,10 +84079,10 @@ var ts;
84072
84079
  }
84073
84080
  // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
84074
84081
  // (TS Exceptions: namespaces, function overloads, enums, and interfaces)
84075
- if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) {
84082
+ if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
84076
84083
  return;
84077
84084
  }
84078
- var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
84085
+ var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
84079
84086
  if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
84080
84087
  // it is legal to merge type alias with other values
84081
84088
  // so count should be either 1 (just type alias) or 2 (type alias + merged value)
@@ -126784,14 +126791,15 @@ var ts;
126784
126791
  : "linkplain";
126785
126792
  var parts = [linkPart("{@" + prefix + " ")];
126786
126793
  if (!link.name) {
126787
- if (link.text)
126794
+ if (link.text) {
126788
126795
  parts.push(linkTextPart(link.text));
126796
+ }
126789
126797
  }
126790
126798
  else {
126791
126799
  var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
126792
126800
  var suffix = findLinkNameEnd(link.text);
126793
126801
  var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
126794
- var text = link.text.slice(suffix);
126802
+ var text = skipSeparatorFromLinkText(link.text.slice(suffix));
126795
126803
  var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
126796
126804
  if (decl) {
126797
126805
  parts.push(linkNamePart(name, decl));
@@ -126806,6 +126814,15 @@ var ts;
126806
126814
  return parts;
126807
126815
  }
126808
126816
  ts.buildLinkParts = buildLinkParts;
126817
+ function skipSeparatorFromLinkText(text) {
126818
+ var pos = 0;
126819
+ if (text.charCodeAt(pos++) === 124 /* bar */) {
126820
+ while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
126821
+ pos++;
126822
+ return text.slice(pos);
126823
+ }
126824
+ return text;
126825
+ }
126809
126826
  function findLinkNameEnd(text) {
126810
126827
  if (text.indexOf("()") === 0)
126811
126828
  return 2;
@@ -138042,9 +138059,18 @@ var ts;
138042
138059
  JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations;
138043
138060
  function getDisplayPartsFromComment(comment, checker) {
138044
138061
  if (typeof comment === "string") {
138045
- return [ts.textPart(comment)];
138062
+ return [ts.textPart(skipSeparatorFromComment(comment))];
138046
138063
  }
138047
- return ts.flatMap(comment, function (node) { return node.kind === 319 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); });
138064
+ return ts.flatMap(comment, function (node) { return node.kind === 319 /* JSDocText */ ? [ts.textPart(skipSeparatorFromComment(node.text))] : ts.buildLinkParts(node, checker); });
138065
+ }
138066
+ function skipSeparatorFromComment(text) {
138067
+ var pos = 0;
138068
+ if (text.charCodeAt(pos++) === 45 /* minus */) {
138069
+ while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
138070
+ pos++;
138071
+ return text.slice(pos);
138072
+ }
138073
+ return text;
138048
138074
  }
138049
138075
  function getCommentDisplayParts(tag, checker) {
138050
138076
  var comment = tag.comment, kind = tag.kind;
@@ -155422,7 +155448,7 @@ var ts;
155422
155448
  /*dotDotDotToken*/ undefined,
155423
155449
  /*name*/ names && names[i] || "arg" + i,
155424
155450
  /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
155425
- /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */),
155451
+ /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */),
155426
155452
  /*initializer*/ undefined);
155427
155453
  parameters.push(newParameter);
155428
155454
  }
@@ -155450,11 +155476,10 @@ var ts;
155450
155476
  var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
155451
155477
  var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
155452
155478
  if (someSigHasRestParameter) {
155453
- var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
155454
155479
  var restParameter = ts.factory.createParameterDeclaration(
155455
155480
  /*decorators*/ undefined,
155456
155481
  /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
155457
- /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, anyArrayType,
155482
+ /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)),
155458
155483
  /*initializer*/ undefined);
155459
155484
  parameters.push(restParameter);
155460
155485
  }
@@ -157823,7 +157848,7 @@ var ts;
157823
157848
  ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
157824
157849
  // For understanding how skipTrivia functioned:
157825
157850
  ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)");
157826
- if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) {
157851
+ if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
157827
157852
  return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
157828
157853
  }
157829
157854
  if (nodeToCheck.flags & 8388608 /* Ambient */) {
@@ -158003,13 +158028,16 @@ var ts;
158003
158028
  if (ts.isStatement(node)) {
158004
158029
  return [node];
158005
158030
  }
158006
- else if (ts.isExpressionNode(node)) {
158031
+ if (ts.isExpressionNode(node)) {
158007
158032
  // If our selection is the expression in an ExpressionStatement, expand
158008
158033
  // the selection to include the enclosing Statement (this stops us
158009
158034
  // from trying to care about the return value of the extracted function
158010
158035
  // and eliminates double semicolon insertion in certain scenarios)
158011
158036
  return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
158012
158037
  }
158038
+ if (isStringLiteralJsxAttribute(node)) {
158039
+ return node;
158040
+ }
158013
158041
  return undefined;
158014
158042
  }
158015
158043
  function isScope(node) {
@@ -158819,7 +158847,7 @@ var ts;
158819
158847
  // Unfortunately, this code takes advantage of the knowledge that the generated method
158820
158848
  // will use the contextual type of an expression as the return type of the extracted
158821
158849
  // method (and will therefore "use" all the types involved).
158822
- if (inGenericContext && !isReadonlyArray(targetRange.range)) {
158850
+ if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
158823
158851
  var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
158824
158852
  recordTypeParameterUsages(contextualType);
158825
158853
  }
@@ -159144,7 +159172,11 @@ var ts;
159144
159172
  }
159145
159173
  }
159146
159174
  function isInJSXContent(node) {
159147
- return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
159175
+ return isStringLiteralJsxAttribute(node) ||
159176
+ (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
159177
+ }
159178
+ function isStringLiteralJsxAttribute(node) {
159179
+ return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
159148
159180
  }
159149
159181
  })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
159150
159182
  })(refactor = ts.refactor || (ts.refactor = {}));
@@ -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.20220221";
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;
@@ -9565,7 +9565,7 @@ var ts;
9565
9565
  Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
9566
9566
  Wrap_invalid_character_in_an_expression_container: diag(95108, ts.DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"),
9567
9567
  Wrap_all_invalid_characters_in_an_expression_container: diag(95109, ts.DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"),
9568
- Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig.json to read more about this file"),
9568
+ Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig to read more about this file"),
9569
9569
  Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
9570
9570
  Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
9571
9571
  Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, ts.DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"),
@@ -40452,7 +40452,7 @@ var ts;
40452
40452
  var result = [];
40453
40453
  result.push("{");
40454
40454
  result.push(tab + "\"compilerOptions\": {");
40455
- result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
40455
+ result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */");
40456
40456
  result.push("");
40457
40457
  // Print out each row, aligning all the descriptions on the same column.
40458
40458
  for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
@@ -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 */;
@@ -70045,7 +70041,7 @@ var ts;
70045
70041
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
70046
70042
  someType(type, isGenericTypeWithUnionConstraint) &&
70047
70043
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
70048
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
70044
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
70049
70045
  }
70050
70046
  function isExportOrExportExpression(location) {
70051
70047
  return !!ts.findAncestor(location, function (n) {
@@ -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
  }
@@ -82262,9 +82267,9 @@ var ts;
82262
82267
  var containsArguments = containsArgumentsReference(node);
82263
82268
  if (containsArguments) {
82264
82269
  var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
82265
- if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82270
+ if (isJs && lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82266
82271
  lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
82267
- errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
82272
+ error(lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
82268
82273
  }
82269
82274
  }
82270
82275
  else {
@@ -82274,7 +82279,9 @@ var ts;
82274
82279
  return;
82275
82280
  }
82276
82281
  if (ts.isQualifiedName(name)) {
82277
- errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82282
+ if (isJs) {
82283
+ error(name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82284
+ }
82278
82285
  }
82279
82286
  else {
82280
82287
  errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
@@ -83867,10 +83874,10 @@ var ts;
83867
83874
  }
83868
83875
  // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
83869
83876
  // (TS Exceptions: namespaces, function overloads, enums, and interfaces)
83870
- if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) {
83877
+ if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
83871
83878
  return;
83872
83879
  }
83873
- var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
83880
+ var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
83874
83881
  if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
83875
83882
  // it is legal to merge type alias with other values
83876
83883
  // so count should be either 1 (just type alias) or 2 (type alias + merged value)
@@ -55,7 +55,6 @@
55
55
  "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433": "命名空间声明必须位于与之合并的类或函数所在的相同文件内。",
56
56
  "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "命名空间声明不能位于与之合并的类或函数前",
57
57
  "A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module_1235": "命名空间声明只允许位于命名空间或模块的顶层。",
58
- "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384": "具有类型参数的 \"new\" 表达式的后面必须始终是带括号的参数列表。",
59
58
  "A_non_dry_build_would_build_project_0_6357": "非 -dry 生成将生成项目“{0}”",
60
59
  "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 -dry 生成将删除以下文件: {0}",
61
60
  "A_non_dry_build_would_update_output_of_project_0_6375": "非干燥生成将更新项目 \"{0}\" 的输出",
@@ -491,6 +490,8 @@
491
490
  "Declare_property_0_90016": "声明属性“{0}”",
492
491
  "Declare_static_method_0_90024": "声明静态方法“{0}”",
493
492
  "Declare_static_property_0_90027": "声明静态属性“{0}”",
493
+ "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270": "装饰器函数返回类型“{0}”不可分配到类型“{1}”。",
494
+ "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271": "装饰器函数返回类型为“{0}”,但预期为“void”或“any”。",
494
495
  "Decorators_are_not_valid_here_1206": "修饰器在此处无效。",
495
496
  "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207": "不能向多个同名的 get/set 访问器应用修饰器。",
496
497
  "Decorators_may_not_be_applied_to_this_parameters_1433": "修饰器不能应用于 “this” 参数。",
@@ -1197,6 +1198,7 @@
1197
1198
  "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "所需的类型参数可能不遵循可选类型参数。",
1198
1199
  "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "在位置“{1}”的缓存中找到模块“{0}”的解析。",
1199
1200
  "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241": "在位置“{1}”的缓存中找到类型引用指令“{0}”的解析。",
1201
+ "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452": "仅当“moduleResolution”为“node12”或“nodenext”时才支持解析模式。",
1200
1202
  "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "只将 \"keyof\" 解析为字符串值的属性名称(不含数字或符号)。",
1201
1203
  "Resolving_module_0_from_1_6086": "======== 正在从“{1}”解析模块“{0}”。========",
1202
1204
  "Resolving_module_name_0_relative_to_base_url_1_2_6094": "正在相对于基 URL“{1}”-“{2}”解析模块名“{0}”。",
@@ -1498,6 +1500,7 @@
1498
1500
  "Type_0_has_no_construct_signatures_2761": "类型 \"{0}\" 没有构造签名。",
1499
1501
  "Type_0_has_no_matching_index_signature_for_type_1_2537": "类型“{0}”没有匹配的类型“{1}”的索引签名。",
1500
1502
  "Type_0_has_no_properties_in_common_with_type_1_2559": "类型“{0}”与类型“{1}”不具有相同的属性。",
1503
+ "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635": "类型“{0}”没有类型参数列表适用的签名。",
1501
1504
  "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739": "类型“{0}”缺少类型“{1}”中的以下属性: {2}",
1502
1505
  "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740": "类型“{0}”缺少类型“{1}”的以下属性: {2} 及其他 {3} 项。",
1503
1506
  "Type_0_is_not_a_constructor_function_type_2507": "类型“{0}”不是构造函数类型。",
@@ -1628,7 +1631,7 @@
1628
1631
  "Variable_declaration_not_allowed_at_this_location_1440": "此位置不允许使用变量声明。",
1629
1632
  "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "源中位置 {0} 的可变元素与目标中位置 {1} 的元素不匹配。",
1630
1633
  "Version_0_6029": "版本 {0}",
1631
- "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file_95110": "请访问 https://aka.ms/tsconfig.json,了解有关此文件的详细信息",
1634
+ "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "请访问 https://aka.ms/tsconfig,了解有关此文件的详细信息",
1632
1635
  "WATCH_OPTIONS_6918": "监视选项",
1633
1636
  "Watch_and_Build_Modes_6250": "观看和生成模式",
1634
1637
  "Watch_input_files_6005": "监视输入文件。",
@@ -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\"。",