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.

[plugin-proposal-optional-chaining] Loose mode produces unoptimized code for class methods

See original GitHub issue

Bug Report

  • I would like to work on a fix!

Current Behavior The loose mode of optional-chaining plugin compiles class methods in non-optimized way repeating the call to the method instead of remembering its result.

It does not happen for function call though.

Input Code

  • REPL or Repo link if applicable: Runkit.
a.get(b)?.();

compiles to:

a.get(b) == null ? void 0 : a.get(b)();

Expected behavior/code The result of method call should be memoized as it happens in the strict mode.

var a$get;

(a$get = a.get(b)) == null ? void 0 : a$get();

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

  • Filename: babel.config.js
{
    plugins: [[require('@babel/plugin-proposal-optional-chaining'), {loose: true}]]
}

Environment

  • Babel version(s): 7.8.4
  • Node/npm version: v13.5.0/6.13.4
  • OS: Windows 10
  • Monorepo: Lerna
  • How you are using Babel: cli/programmatically

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
oliverdunkcommented, Feb 1, 2020

I’d love to work on this one 😃

1reaction
jridgewellcommented, Mar 2, 2020

All good. Happy to review an unfinished PR, please open one when you can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/plugin-proposal-optional-chaining
Example · Accessing deeply nested properties · Calling deeply nested functions · Constructing deeply nested classes · Deleting deeply nested properties.
Read more >
Learning JavaScript Design Patterns
To provide a holistic understanding of the past and present of design patterns, this book will present ES2015+ and class (ES5) versions of...
Read more >
Read Understanding ECMAScript 6 | Leanpub
Chapter 9: Introducing JavaScript Classes introduces the first formal ... Each methods accept two arguments: the text to search for and an optional...
Read more >
babel/plugin-proposal-optional-chaining Code Examples - Snyk
To help you get started, we've selected a few @babel/plugin-proposal-optional-chaining examples, based on popular ways it is used in public projects.
Read more >
WebGPU - W3C
This is a general problem with all general-purpose computation capabilities on the Web: JavaScript, WebAssembly or WebGL. WebGPU only makes some workloads ...
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