question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
macabeuscommented, Jan 4, 2020

I’m working in a fix to this bug.

0reactions
alex-kinokoncommented, Mar 22, 2020

@nicolo-ribaudo There’s a bug filed at the TypeScript repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ABC conjecture - Wikipedia
The conjecture essentially states that the product of the distinct prime factors of abc is usually not much smaller than c. A number...
Read more >
Whats the difference between "abc" and {"abc"} in C?
The first line line defines an array of four bytes. These two are equivalent: char str[4] = "abc"; char str[4] = {'a', 'b',...
Read more >
Activity-based costing (ABC)
ABC focuses attention on cost drivers, the activities that cause costs to increase.
Read more >
collections.abc — Abstract Base Classes for Containers ...
An issubclass() or isinstance() test for an interface works in one of three ways. 1) A newly written class can inherit directly from...
Read more >
The Disadvantages & Advantages of Activity-Based Costing
ABC produces more accurate costing of products by essentially converting broad indirect costs into direct costs of production. It determines the costs of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found