Skip to content

[ts] bug with arrow functions in ternaries #4241

@evanw

Description

@evanw

Copying this over from babel/babel#17140 (esbuild has a similar bug):

let a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, i = 0
let cases = [
  // These cases match tsc
  (a = b) : number => c,
  a ? (b = c) : number => d : (e = f),
  a ? (b = c) : number => d : (e = f) : number => g,
  a ? (b ? (c = d) : number => e : (f = g)) : h => i,

  // These cases currently fail (but tsc handles them)
  a ? (b = c) : d => e,
  a ? b ? c : (d = e) : f => g,
  a ? b ? (c = d) => e : (f = g) : h => i,
  a ? b ? (c = d) : number => e : (f = g) : h => i,
]

Live example: link

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions