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.

Nested ternary operator does not work when object plugin is used

See original GitHub issue

When the object plugin is registered, a nested ternary operator no longer works. jsep throws an exception that it expects a : at some position.

That’s what works without the object plugin, but not with the object plugin:

import jsep from "jsep";
import object from "@jsep-plugin/object";
jsep.plugins.register(object);

let works = jsep("a ? 0 : 1"); // works also with `object` plugin
let worksAsWell = jsep("a ? 0 : (b ? 1 : 2)"); // works also with `object` plugin
let doesNotWork = jsep("a ? 0 : b ? 1 : 2"); // throws exception as soon as the `object` plugin is registered

Other plugins like the comment plugin do not harm.

Looks like an “unresolved technical issue” 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
untersalmbergercommented, Sep 24, 2021

You guys are amazing! I love your work!

1reaction
6utt3rflycommented, Sep 24, 2021

Thanks for reporting @untersalmberger . I can see the issue and will try to fix it sometime this weekend 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - A somewhat painful triple-nested ternary operator
To my personal taste, a carefully aligned nested ternary beats the if-else mess: const H = C == 0 ? null : V...
Read more >
no-nested-ternary - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Nested Ternaries are Great - Medium
People try to use ternary statements as if they're if statements. That doesn't work, because ternary expressions are expressions, not statements.
Read more >
Nested ternary formatting - add indents back #5814 - GitHub
I know there is some reasoning why nested ternary indent was removed, but it's much harder to read code now.
Read more >
PHP static code analysis: Ternary operators should not be ...
Ternary operators should not be nested ... Just because you can do something, doesn't mean you should, and that's the case with nested...
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