diff --git a/src/rules/noVoidExpressionRule.ts b/src/rules/noVoidExpressionRule.ts index 798924dd4b6..ff1b0f87752 100644 --- a/src/rules/noVoidExpressionRule.ts +++ b/src/rules/noVoidExpressionRule.ts @@ -104,6 +104,10 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker): void { // Something like "x && console.log(x)". case ts.SyntaxKind.BinaryExpression: return isParentAllowedVoid(node.parent); + + // Something like "!!cond ? console.log(true) : console.log(false)" + case ts.SyntaxKind.ConditionalExpression: + return true; default: return false; } diff --git a/test/rules/no-void-expression/default/test.ts.lint b/test/rules/no-void-expression/default/test.ts.lint index 663fe260c75..1322aff7aee 100644 --- a/test/rules/no-void-expression/default/test.ts.lint +++ b/test/rules/no-void-expression/default/test.ts.lint @@ -24,4 +24,6 @@ declare function doIt(): void; declare function doAsync(): Promise; declare function print(strs: TemplateStringsArray): void; +!!data ? console.info(message, data) : console.info(message); + [0]: Expression has type `void`. Put it on its own line as a statement.