onEnter = (e: KeyboardEvent) => {
e.keyCode === 13 ? fetchData(url) : null;
};
with tslint.json configuration:
"no-unused-expressions": [true, "allow-fast-null-checks"],
Referring to the null value -[tslint] unused expression, expected an assignment or function call (no-unused-expression)
Allow ternary operations that evaluate to null
@james-prado this behavior is completely expected. null; by itself is rejected with the same error. use an if statement for this pattern.
Ternary operator shorthand is a natural use case here, we don't care about the false case. In comparison if condition is just noise.
if (cond) {
effect()
}
cond ? effect() : null
Most helpful comment
Ternary operator shorthand is a natural use case here, we don't care about the
falsecase. In comparisonifcondition is just noise.