Warn/error on pointless expression? #12576
Labels
Out of Scope
This idea sits outside of the TypeScript language design constraints
Suggestion
An idea for TypeScript
This is a feature request.
This is an example to some similar code I recently encountered. It was a little bit more complex in the real code.
Can you see the problem on first glance? Probably. But with more noise and stress around me, I couldn't see the bug for a while. "Of course"
foo.bar.baz.nope === 2;
should befoo.bar.baz.nope === 2;
. There is no point to have a line likefoo.bar.baz.nope === 2;
.Maybe TypeScript could warn/error for cases like this with an additional setting (similar to settings like
noUnusedLocals
ornoUnusedParameters
). MaybenoUnusedExpressions
? If expression is used without assigning the value to a variable or without being used insideif ()
and similar cases, I don't see why anyone would want to write an expression. If someone would write that to invoke some side effects that would be a bad style, too (IMHO).The text was updated successfully, but these errors were encountered: