Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Make strict-boolean-expressions test consistent w/ ts 2.0 (#2082)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchen63 authored Jan 20, 2017
1 parent 8207eff commit 2aba847
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/rules/strictBooleanExpressionsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function stringOr(parts: string[]): string {
}

function isUnionType(type: ts.Type): type is ts.UnionType {
return Lint.isTypeFlagSet(type, ts.TypeFlags.Union);
return Lint.isTypeFlagSet(type, ts.TypeFlags.Union) && !Lint.isTypeFlagSet(type, ts.TypeFlags.Enum);
}

declare module "typescript" {
Expand Down
10 changes: 5 additions & 5 deletions test/rules/strict-boolean-expressions/default/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ boolType && strType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.]
boolType && objType && enumType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.]
~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it could be an enum. Only booleans are allowed.]
~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is an enum. Only booleans are allowed.]
bwrapType && boolType;
~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.]

Expand All @@ -44,7 +44,7 @@ bwrapType || boolType;
~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.]
objType || boolType || enumType;
~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.]
~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it could be an enum. Only booleans are allowed.]
~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is an enum. Only booleans are allowed.]

boolExpr && strType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.]
Expand Down Expand Up @@ -78,7 +78,7 @@ classType ? strType : undefined;
bwrapType ? 1 : 0;
~~~~~~~~~ [This type is not allowed in the condition because it is always truthy. Only booleans are allowed.]
enumType ? 0 : 1;
~~~~~~~~ [This type is not allowed in the condition because it could be an enum. Only booleans are allowed.]
~~~~~~~~ [This type is not allowed in the condition because it is an enum. Only booleans are allowed.]

/*** Valid ***/
boolFn() ? numType : strType;
Expand All @@ -93,7 +93,7 @@ boolType ? strType : undefined;
!objType;
~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.]
!enumType;
~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it could be an enum. Only booleans are allowed.]
~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is an enum. Only booleans are allowed.]
!!classType;
~~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.]
!bwrapType;
Expand Down Expand Up @@ -178,4 +178,4 @@ do { /* statements */ } while (boolType);
for (let j = 0; j; j++) { /* statements */ }
~ [This type is not allowed in the 'for' condition because it is a number. Only booleans are allowed.]
/*** Valid ***/
for (let j = 0; j > numType; j++) { /* statements */ }
for (let j = 0; j > numType; j++) { /* statements */ }

0 comments on commit 2aba847

Please sign in to comment.