-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
It's easy to write code like this (#10802)
// This code does not do what it appears to!
let arr = [];
switch(arr.length) {
case 0, 1:
return 'zero or one';
default:
return 'more than one';
}Or this
let x = Math.pow((3, 5)); // x = NaN, wat?Or this:
let a = [(3 + 4), ((1 + 1, 8) * 4)]; // oopsWe should disallow left comma operands when they are side-effect free. An expression is side-effect free (SEF) if it is:
- A literal
- An identifier
- A unary operator whose operand is SEF
- A binary operator, other than the assignment operators, whose operands are both SEF
- A ternary operator whose operands are all SEF
- A parenthesized expression which is SEF
- A function expression
kitsonk, ahejlsberg and yortus
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript