Skip to content

Support for nullish coalescing is poor #213

@esb

Description

@esb

It appears that the only way to get a nullish coalescing operator (??) is to enable the --nullish option, but this is a global option, so every use of a logical or or || turns into a ??. This means that normal logical tests are broken.

if (a == 1) || (a == 2) && (b== 3)
  ...stuff
end

results in

if ((a === 1) ?? (a === 2) && (b === 3)) {
  ...stuff
}

which will throw a syntax error as it's nonsense.

The problem is that there doesn't seem to be a way of using nullish coalescing without this option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions