Skip to content

Ember assert is not correctly transformed when using optional chaining #410

@mongoose700

Description

@mongoose700

If I start with this code

import { assert } from '@ember/debug';

const foo = { bar: { baz: 'something' } };
assert('baz', foo.bar?.baz);

it gets transformed into

const foo = {
  bar: {
    baz: 'something'
  }
};
(true && !(_foo$bar.baz) && Ember.assert('baz', (_foo$bar = foo.bar) === null || _foo$bar === void 0 ? void 0 : _foo$bar.baz));

The first check for !(_foo$bar.baz) is performed before the (_foo$bar = foo.bar) assignment, which means it will always throw an error, regardless of the actual value.

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