Skip to content

Commit 1ad443e

Browse files
A bit of cleanup.
1 parent 465bcc6 commit 1ad443e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24518,7 +24518,7 @@ namespace ts {
2451824518
resultType = numberType;
2451924519
}
2452024520
// At least one is assignable to bigint, so check that both are
24521-
else if (isTypeAssignableToKind(leftType, TypeFlags.BigIntLike) && isTypeAssignableToKind(rightType, TypeFlags.BigIntLike)) {
24521+
else if (bothAreBigIntLike(leftType, rightType)) {
2452224522
switch (operator) {
2452324523
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
2452424524
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
@@ -24528,7 +24528,7 @@ namespace ts {
2452824528
}
2452924529
// Exactly one of leftType/rightType is assignable to bigint
2453024530
else {
24531-
reportOperatorError((awaitedLeft, awaitedRight) => isTypeAssignableToKind(awaitedLeft, TypeFlags.BigIntLike) && isTypeAssignableToKind(awaitedRight, TypeFlags.BigIntLike));
24531+
reportOperatorError(bothAreBigIntLike);
2453224532
resultType = errorType;
2453324533
}
2453424534
if (leftOk && rightOk) {
@@ -24578,9 +24578,9 @@ namespace ts {
2457824578
// might be missing an await without doing an exhaustive check that inserting
2457924579
// await(s) will actually be a completely valid binary expression.
2458024580
const closeEnoughKind = TypeFlags.NumberLike | TypeFlags.BigIntLike | TypeFlags.StringLike | TypeFlags.AnyOrUnknown;
24581-
reportOperatorError((awaitedLeft, awaitedRight) =>
24582-
isTypeAssignableToKind(awaitedLeft, closeEnoughKind) &&
24583-
isTypeAssignableToKind(awaitedRight, closeEnoughKind));
24581+
reportOperatorError((left, right) =>
24582+
isTypeAssignableToKind(left, closeEnoughKind) &&
24583+
isTypeAssignableToKind(right, closeEnoughKind));
2458424584
return anyType;
2458524585
}
2458624586

@@ -24648,6 +24648,10 @@ namespace ts {
2464824648
return Debug.fail();
2464924649
}
2465024650

24651+
function bothAreBigIntLike(left: Type, right: Type): boolean {
24652+
return isTypeAssignableToKind(left, TypeFlags.BigIntLike) && isTypeAssignableToKind(right, TypeFlags.BigIntLike);
24653+
}
24654+
2465124655
function checkAssignmentDeclaration(kind: AssignmentDeclarationKind, rightType: Type) {
2465224656
if (kind === AssignmentDeclarationKind.ModuleExports) {
2465324657
for (const prop of getPropertiesOfObjectType(rightType)) {
@@ -24760,7 +24764,7 @@ namespace ts {
2476024764
if (!wouldWorkWithAwait && isRelated) {
2476124765
[effectiveLeft, effectiveRight] = getBaseTypesIfUnrelated(leftType, rightType, isRelated);
2476224766
}
24763-
let [leftStr, rightStr] = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight);
24767+
const [leftStr, rightStr] = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight);
2476424768
if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
2476524769
errorAndMaybeSuggestAwait(
2476624770
errNode,

0 commit comments

Comments
 (0)