-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
π Search Terms
"if statement", "constant condition"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about common bugs
β― Playground Link
π» Code
const someCheckingFunction = (param1: string, param2: string, optionalParam3 = true) => {
// do stuff
return true;
}
// always false, result of someCheckingFunction always ignored
if(someCheckingFunction("param1", "param2"), false) {
}
// dependent on result of someCheckingFunction
if(someCheckingFunction("param1", "param2", false)) {
}π Actual behavior
Due to a mistake in my bracket placement as seen in the example, I accidentally learned that multiple arguments in an if statement are possible.
Currently that means:
- only the last argument is used for the if statement check
- even for constant conditions there is not error visible
π Expected behavior
What I would expect:
- don't allow multiple arguments, this only happens because someone made an error
- at least show an error if there is a constant condition
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript