You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simpler repro is just to have () in the then of the ternary expression. This also causes weird parsing to occur:
true ? (a): function(){returntrue;}
Transpiled as
true ? function(a){returntrue;} : ;
RyanCavanaugh
changed the title
Incorrect parse of parenthesized comma operator in second ternary operator operand
Incorrect parse of parenthesized expression in second ternary operator operand
Mar 28, 2019
Looks like this stems from us parsing JSDoc function types function(), (or function(number, string) or function(number): number) outside of JSDoc. We should probably just disable that.
The quickfix is opportunistic in nature - we don't actually expect anyone to write let x: function(): void, since that's never been valid in anything. It's moreso for catching things like let x: string? (since postfix questionmark is a thing in flow/jsdoc but not TS)
TypeScript Version: 3.4.0-dev.20190328
Search Terms:
expression expected, Ternary operation, shorthand
Code
Expected behavior:
Actual behavior:
Playground Link:
https://www.typescriptlang.org/play/#src=let%20a%3B%0D%0Alet%20b%3B%0D%0Aconst%20c%20%3D%20true%20%3F%20(a%20%3D%201%2C%20b%20%3D%202)%20%3A%20function%20()%20%7B%20return%20true%3B%20%7D%3B
Related Issues:
#16241
#11582
The text was updated successfully, but these errors were encountered: