Skip to content

let? ignores variable name in generated javascript #8085

@glennsl

Description

@glennsl

This reduces readability and causes problems with js interop.

Example:

let fromString: string => option<int> = str => {
  let? Some(num) = str->Float.fromString
  num === %raw("num | 0") && Float.isFinite(num) ? Obj.magic(num) : None
}

generates:

function fromString(str) {
  let x = Stdlib_Float.fromString(str);
  if (x !== undefined && !(x === (num | 0) && isFinite(x))) {
    return;
  } else {
    return x;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions