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

a?.b.c() produces different result than a?.b!.c() #10959

Open
proteriax opened this issue Jan 4, 2020 · 3 comments · May be fixed by #10961
Open

a?.b.c() produces different result than a?.b!.c() #10959

proteriax opened this issue Jan 4, 2020 · 3 comments · May be fixed by #10961

Comments

@proteriax
Copy link

@proteriax proteriax commented Jan 4, 2020

Bug Report

  • I would like to work on a fix!

Input Code

  • REPL or Repo link if applicable:
a?.b.c()
a?.b!.c()

Actual behavior

"use strict";

var _a, _a2;

(_a = a) === null || _a === void 0 ? void 0 : _a.b.c();
((_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b).c();

Expected behavior/code
The ! should have no effect on the produced code.

Problem: Suppose a is null, then the second line can be reduced to:

   ((_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b).c()
=> ((a2 = null) === null || _a2 === void 0 ? void 0 : _a2.b).c()
=> (null === null || _a2 === void 0 ? void 0 : _a2.b).c()
=> (true ? void 0 : _a2.b).c()
=> undefined.c()

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "presets": ["@babel/preset-typescript", "@babel/preset-stage-3"]
}

Environment

Possible Solution
¯\_(ツ)_/

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Jan 4, 2020

Hey @proteriax! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@macabeus

This comment has been minimized.

Copy link
Contributor

@macabeus macabeus commented Jan 4, 2020

I'm working in a fix to this bug.

@macabeus

This comment has been minimized.

Copy link
Contributor

@macabeus macabeus commented Jan 4, 2020

PR opened: #10961

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.