-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrap subexpressions of conditional expressions in parens if necessary (…
- Loading branch information
Showing
5 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/baselines/reference/commaOperatorInConditionalExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//// [commaOperatorInConditionalExpression.ts] | ||
function f (m: string) { | ||
[1, 2, 3].map(i => { | ||
return true? { [m]: i } : { [m]: i + 1 } | ||
}) | ||
} | ||
|
||
//// [commaOperatorInConditionalExpression.js] | ||
function f(m) { | ||
[1, 2, 3].map(function (i) { | ||
return true ? (_a = {}, _a[m] = i, _a) : (_b = {}, _b[m] = i + 1, _b); | ||
var _a, _b; | ||
}); | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/commaOperatorInConditionalExpression.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
=== tests/cases/compiler/commaOperatorInConditionalExpression.ts === | ||
function f (m: string) { | ||
>f : Symbol(f, Decl(commaOperatorInConditionalExpression.ts, 0, 0)) | ||
>m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12)) | ||
|
||
[1, 2, 3].map(i => { | ||
>[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) | ||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) | ||
>i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18)) | ||
|
||
return true? { [m]: i } : { [m]: i + 1 } | ||
>m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12)) | ||
>i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18)) | ||
>m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12)) | ||
>i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18)) | ||
|
||
}) | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/commaOperatorInConditionalExpression.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
=== tests/cases/compiler/commaOperatorInConditionalExpression.ts === | ||
function f (m: string) { | ||
>f : (m: string) => void | ||
>m : string | ||
|
||
[1, 2, 3].map(i => { | ||
>[1, 2, 3].map(i => { return true? { [m]: i } : { [m]: i + 1 } }) : { [x: string]: number; }[] | ||
>[1, 2, 3].map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } | ||
>[1, 2, 3] : number[] | ||
>1 : 1 | ||
>2 : 2 | ||
>3 : 3 | ||
>map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } | ||
>i => { return true? { [m]: i } : { [m]: i + 1 } } : (i: number) => { [x: string]: number; } | ||
>i : number | ||
|
||
return true? { [m]: i } : { [m]: i + 1 } | ||
>true? { [m]: i } : { [m]: i + 1 } : { [x: string]: number; } | ||
>true : true | ||
>{ [m]: i } : { [x: string]: number; } | ||
>m : string | ||
>i : number | ||
>{ [m]: i + 1 } : { [x: string]: number; } | ||
>m : string | ||
>i + 1 : number | ||
>i : number | ||
>1 : 1 | ||
|
||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function f (m: string) { | ||
[1, 2, 3].map(i => { | ||
return true? { [m]: i } : { [m]: i + 1 } | ||
}) | ||
} |