Nested ternary operator does not work when object plugin is used
See original GitHub issueWhen 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:
- Created 2 years ago
- Comments:6
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You guys are amazing! I love your work!
Thanks for reporting @untersalmberger . I can see the issue and will try to fix it sometime this weekend 😃