🔎 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
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBBIFsCmBhAFk4BrAlmA5gGICuYwUO4MAvDABQAOAhgE5MICMAXHFC3vgA0MZmwQAmHtH4FhIBhXBMANgAVW7AMw0YfYkgCUNAHwwA3gCgY1mAHpbMACYhexAGZurNlkijEWYLos+gDcFgC+Fhb2MCoA7kwAnhAwbioQSMI+EMTKsCBucIioGNgCJGSKgfFJKTj4YCA+jhY4bnTwyOiYuAQV5JRgdABEouwcw8KjGhLDBsJpyhlGljYwEVExjkgMSGDbYPmB2bn5hZ0lPeWkA+Ct7RfdZX03VSNjnJMw02LiX4vLFZeawRIA
💻 Code
constsomeCheckingFunction=(param1: string,param2: string,optionalParam3=true)=>{// do stuffreturntrue;}// always false, result of someCheckingFunction always ignoredif(someCheckingFunction("param1","param2"),false){}// dependent on result of someCheckingFunctionif(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
🔎 Search Terms
"if statement", "constant condition"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBBIFsCmBhAFk4BrAlmA5gGICuYwUO4MAvDABQAOAhgE5MICMAXHFC3vgA0MZmwQAmHtH4FhIBhXBMANgAVW7AMw0YfYkgCUNAHwwA3gCgY1mAHpbMACYhexAGZurNlkijEWYLos+gDcFgC+Fhb2MCoA7kwAnhAwbioQSMI+EMTKsCBucIioGNgCJGSKgfFJKTj4YCA+jhY4bnTwyOiYuAQV5JRgdABEouwcw8KjGhLDBsJpyhlGljYwEVExjkgMSGDbYPmB2bn5hZ0lPeWkA+Ct7RfdZX03VSNjnJMw02LiX4vLFZeawRIA
💻 Code
🙁 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:
🙂 Expected behavior
What I would expect:
Additional information about the issue
No response