DanielXMoore / Civet

A TypeScript superset that favors more types and less typing
https://civet.dev
MIT License
1.33k stars 28 forks source link

Empty block following pattern in switch expression generates invalid JS #1264

Closed bbrk24 closed 1 month ago

bbrk24 commented 1 month ago

Input:

f := (x) => switch x
  [_]
    // nothing
  else
    foo()

Output (with --js to make the len function shorter):

function len(arr, length) { return arr.length === length }
const f = (x) => { if(Array.isArray(x) && len(x, 1)) {return const [_] = x;}
else  {
    return foo()
  } }

return const isn't a valid type of statement.