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.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220217";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220218";
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;
@@ -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 */;
@@ -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
  }
@@ -84072,10 +84077,10 @@ var ts;
84072
84077
  }
84073
84078
  // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
84074
84079
  // (TS Exceptions: namespaces, function overloads, enums, and interfaces)
84075
- if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) {
84080
+ if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
84076
84081
  return;
84077
84082
  }
84078
- var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
84083
+ var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
84079
84084
  if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
84080
84085
  // it is legal to merge type alias with other values
84081
84086
  // so count should be either 1 (just type alias) or 2 (type alias + merged value)
@@ -126784,14 +126789,15 @@ var ts;
126784
126789
  : "linkplain";
126785
126790
  var parts = [linkPart("{@" + prefix + " ")];
126786
126791
  if (!link.name) {
126787
- if (link.text)
126792
+ if (link.text) {
126788
126793
  parts.push(linkTextPart(link.text));
126794
+ }
126789
126795
  }
126790
126796
  else {
126791
126797
  var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
126792
126798
  var suffix = findLinkNameEnd(link.text);
126793
126799
  var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
126794
- var text = link.text.slice(suffix);
126800
+ var text = skipSeparatorFromLinkText(link.text.slice(suffix));
126795
126801
  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
126802
  if (decl) {
126797
126803
  parts.push(linkNamePart(name, decl));
@@ -126806,6 +126812,15 @@ var ts;
126806
126812
  return parts;
126807
126813
  }
126808
126814
  ts.buildLinkParts = buildLinkParts;
126815
+ function skipSeparatorFromLinkText(text) {
126816
+ var pos = 0;
126817
+ if (text.charCodeAt(pos++) === 124 /* bar */) {
126818
+ while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
126819
+ pos++;
126820
+ return text.slice(pos);
126821
+ }
126822
+ return text;
126823
+ }
126809
126824
  function findLinkNameEnd(text) {
126810
126825
  if (text.indexOf("()") === 0)
126811
126826
  return 2;
@@ -155422,7 +155437,7 @@ var ts;
155422
155437
  /*dotDotDotToken*/ undefined,
155423
155438
  /*name*/ names && names[i] || "arg" + i,
155424
155439
  /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
155425
- /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */),
155440
+ /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */),
155426
155441
  /*initializer*/ undefined);
155427
155442
  parameters.push(newParameter);
155428
155443
  }
@@ -155450,11 +155465,10 @@ var ts;
155450
155465
  var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
155451
155466
  var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
155452
155467
  if (someSigHasRestParameter) {
155453
- var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
155454
155468
  var restParameter = ts.factory.createParameterDeclaration(
155455
155469
  /*decorators*/ undefined,
155456
155470
  /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
155457
- /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, anyArrayType,
155471
+ /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)),
155458
155472
  /*initializer*/ undefined);
155459
155473
  parameters.push(restParameter);
155460
155474
  }
@@ -157823,7 +157837,7 @@ var ts;
157823
157837
  ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
157824
157838
  // For understanding how skipTrivia functioned:
157825
157839
  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))) {
157840
+ if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
157827
157841
  return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
157828
157842
  }
157829
157843
  if (nodeToCheck.flags & 8388608 /* Ambient */) {
@@ -158003,13 +158017,16 @@ var ts;
158003
158017
  if (ts.isStatement(node)) {
158004
158018
  return [node];
158005
158019
  }
158006
- else if (ts.isExpressionNode(node)) {
158020
+ if (ts.isExpressionNode(node)) {
158007
158021
  // If our selection is the expression in an ExpressionStatement, expand
158008
158022
  // the selection to include the enclosing Statement (this stops us
158009
158023
  // from trying to care about the return value of the extracted function
158010
158024
  // and eliminates double semicolon insertion in certain scenarios)
158011
158025
  return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
158012
158026
  }
158027
+ if (isStringLiteralJsxAttribute(node)) {
158028
+ return node;
158029
+ }
158013
158030
  return undefined;
158014
158031
  }
158015
158032
  function isScope(node) {
@@ -158819,7 +158836,7 @@ var ts;
158819
158836
  // Unfortunately, this code takes advantage of the knowledge that the generated method
158820
158837
  // will use the contextual type of an expression as the return type of the extracted
158821
158838
  // method (and will therefore "use" all the types involved).
158822
- if (inGenericContext && !isReadonlyArray(targetRange.range)) {
158839
+ if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
158823
158840
  var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
158824
158841
  recordTypeParameterUsages(contextualType);
158825
158842
  }
@@ -159144,7 +159161,11 @@ var ts;
159144
159161
  }
159145
159162
  }
159146
159163
  function isInJSXContent(node) {
159147
- return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
159164
+ return isStringLiteralJsxAttribute(node) ||
159165
+ (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
159166
+ }
159167
+ function isStringLiteralJsxAttribute(node) {
159168
+ return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
159148
159169
  }
159149
159170
  })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
159150
159171
  })(refactor = ts.refactor || (ts.refactor = {}));
@@ -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.20220218";
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;
@@ -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 */;
@@ -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
  }
@@ -84072,10 +84077,10 @@ var ts;
84072
84077
  }
84073
84078
  // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
84074
84079
  // (TS Exceptions: namespaces, function overloads, enums, and interfaces)
84075
- if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) {
84080
+ if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
84076
84081
  return;
84077
84082
  }
84078
- var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
84083
+ var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
84079
84084
  if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
84080
84085
  // it is legal to merge type alias with other values
84081
84086
  // so count should be either 1 (just type alias) or 2 (type alias + merged value)
@@ -126784,14 +126789,15 @@ var ts;
126784
126789
  : "linkplain";
126785
126790
  var parts = [linkPart("{@" + prefix + " ")];
126786
126791
  if (!link.name) {
126787
- if (link.text)
126792
+ if (link.text) {
126788
126793
  parts.push(linkTextPart(link.text));
126794
+ }
126789
126795
  }
126790
126796
  else {
126791
126797
  var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
126792
126798
  var suffix = findLinkNameEnd(link.text);
126793
126799
  var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
126794
- var text = link.text.slice(suffix);
126800
+ var text = skipSeparatorFromLinkText(link.text.slice(suffix));
126795
126801
  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
126802
  if (decl) {
126797
126803
  parts.push(linkNamePart(name, decl));
@@ -126806,6 +126812,15 @@ var ts;
126806
126812
  return parts;
126807
126813
  }
126808
126814
  ts.buildLinkParts = buildLinkParts;
126815
+ function skipSeparatorFromLinkText(text) {
126816
+ var pos = 0;
126817
+ if (text.charCodeAt(pos++) === 124 /* bar */) {
126818
+ while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
126819
+ pos++;
126820
+ return text.slice(pos);
126821
+ }
126822
+ return text;
126823
+ }
126809
126824
  function findLinkNameEnd(text) {
126810
126825
  if (text.indexOf("()") === 0)
126811
126826
  return 2;
@@ -155422,7 +155437,7 @@ var ts;
155422
155437
  /*dotDotDotToken*/ undefined,
155423
155438
  /*name*/ names && names[i] || "arg" + i,
155424
155439
  /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
155425
- /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */),
155440
+ /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */),
155426
155441
  /*initializer*/ undefined);
155427
155442
  parameters.push(newParameter);
155428
155443
  }
@@ -155450,11 +155465,10 @@ var ts;
155450
155465
  var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
155451
155466
  var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
155452
155467
  if (someSigHasRestParameter) {
155453
- var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
155454
155468
  var restParameter = ts.factory.createParameterDeclaration(
155455
155469
  /*decorators*/ undefined,
155456
155470
  /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
155457
- /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, anyArrayType,
155471
+ /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)),
155458
155472
  /*initializer*/ undefined);
155459
155473
  parameters.push(restParameter);
155460
155474
  }
@@ -157823,7 +157837,7 @@ var ts;
157823
157837
  ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
157824
157838
  // For understanding how skipTrivia functioned:
157825
157839
  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))) {
157840
+ if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
157827
157841
  return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
157828
157842
  }
157829
157843
  if (nodeToCheck.flags & 8388608 /* Ambient */) {
@@ -158003,13 +158017,16 @@ var ts;
158003
158017
  if (ts.isStatement(node)) {
158004
158018
  return [node];
158005
158019
  }
158006
- else if (ts.isExpressionNode(node)) {
158020
+ if (ts.isExpressionNode(node)) {
158007
158021
  // If our selection is the expression in an ExpressionStatement, expand
158008
158022
  // the selection to include the enclosing Statement (this stops us
158009
158023
  // from trying to care about the return value of the extracted function
158010
158024
  // and eliminates double semicolon insertion in certain scenarios)
158011
158025
  return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
158012
158026
  }
158027
+ if (isStringLiteralJsxAttribute(node)) {
158028
+ return node;
158029
+ }
158013
158030
  return undefined;
158014
158031
  }
158015
158032
  function isScope(node) {
@@ -158819,7 +158836,7 @@ var ts;
158819
158836
  // Unfortunately, this code takes advantage of the knowledge that the generated method
158820
158837
  // will use the contextual type of an expression as the return type of the extracted
158821
158838
  // method (and will therefore "use" all the types involved).
158822
- if (inGenericContext && !isReadonlyArray(targetRange.range)) {
158839
+ if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
158823
158840
  var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
158824
158841
  recordTypeParameterUsages(contextualType);
158825
158842
  }
@@ -159144,7 +159161,11 @@ var ts;
159144
159161
  }
159145
159162
  }
159146
159163
  function isInJSXContent(node) {
159147
- return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
159164
+ return isStringLiteralJsxAttribute(node) ||
159165
+ (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
159166
+ }
159167
+ function isStringLiteralJsxAttribute(node) {
159168
+ return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
159148
159169
  }
159149
159170
  })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
159150
159171
  })(refactor = ts.refactor || (ts.refactor = {}));