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.

Evaluate simple expressions that resolve to a constant value

See original GitHub issue
css={{ fontSize: 2 + 2 }}

.cc {
  font-size: 4; // reduced to 4
}

handle:

  • multiplication
  • addition
  • subtraction
  • division

on:

  • strings
  • numbers
  • identifiers that resolve to a constant string or number

Use babel path method path.evaluate

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
itsdougescommented, Aug 23, 2020

yeah - finding the bindings works out of the box. we just need some extra code to do the module traversal stuff - i reckon when we start doing the actual work we can refactor this first.

1reaction
pgmanutdcommented, Aug 23, 2020

yups, instead of storing declarations, lets find the bindings. Atleast that binding will be limited to a particular scope right.

Doing like this:

const declarationName = path.node.declarations[0].id.name;
state.declarations[declarationName] = path.node;

might end up with same declarationName. Not sure, but there can be a possibility.

Instead, lets traverse upwards and find the binding. Worst case will be that we have to traverse module boundaries, but thats the worst case right. We can work on a fallback if possible in case we are not able to traverse module boundaries. Nice work btw ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compile-time constants, constant expressions, and constexpr
A constant expression is an expression that can be evaluated by the compiler at compile-time. To be a constant expression, all the values...
Read more >
"function call must have a constant value in a ... - Stack Overflow
I'm using Visual Studio 2015, FYI. Error messages: Error C2131 expression did not evaluate to a constant Basic Server c:\<snip> 28 Error C2131 ......
Read more >
Program to evaluate simple expressions - GeeksforGeeks
utility function to find value of and operand. int value( char c) { return (c - '0' ); }. // This function evaluates...
Read more >
6. Expressions
can be completely resolved at parse time (i.e., constant expressions), and those that can only be resolved at run time. (i.e., variable expressions)....
Read more >
What are Compile-time Constants in Java? - Baeldung
The Java compiler is able to pre-calculate certain values for us at compile time. This allows us to use some variables with expressions...
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