Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec violations with Optional Chaning #1019

Closed
jridgewell opened this issue Mar 20, 2021 · 1 comment · Fixed by #1022
Closed

Spec violations with Optional Chaning #1019

jridgewell opened this issue Mar 20, 2021 · 1 comment · Fixed by #1022

Comments

@jridgewell
Copy link
Contributor

In digging through the transforms you're doing, I've noticed 2 spec violations in Optional Chaining:

  1. Forced call of an optional member expression should propagate the object to the method:

    const o = { m() { return this; } };
    assert.strictEqual((o?.m)(), o, 'receiver is passed to method');
  2. Optional call of eval must be an indirect eval:

    var a = 'global';
    var b = (a => eval?.('a'))('local');
    assert.strictEqual(b, 'global', 'indirect eval cannot see local scope');
@evanw
Copy link
Owner

evanw commented Mar 20, 2021

Thanks for pointing these out. I think what happened here is that I referenced V8 and TypeScript when implementing this, but V8 has since changed its behavior. It looks like TypeScript still has the old behavior, meaning these syntax forms are now hazards for TypeScript users. I will change esbuild to align with V8's new behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants