runtime type consistency in expression evaluation.
See original GitHub issueCurrently, we handle expression evaluation errors with error logs but will return undefined as the result.
This makes components can not predict the types of props in runtime. For example, a component may define a props foo
with type number
which is required, but if the evaluation throws an error, the component may get undefined
as the foo
props value.
Possible solution: do not render components in ImplementWrapper
when expression evaluation failed.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Methods for TypeScript runtime type checking - LogRocket Blog
Explore five methods of performing TypeScript type checks at runtime in this post and learn each of their advantages and disadvantages.
Read more >Evaluating Expressions - Crafting Interpreters
So, to “execute” code, we will evaluate an expression and produce a value. For each kind of ... This type cast happens at...
Read more >How can I evaluate a C# expression dynamically?
While C# doesn't have any support for an Eval method natively, I have a C# eval program that does allow for evaluating C#...
Read more >Chapter 15. Expressions
The Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order, namely, from left to...
Read more >invalid expressions in const-expr and override-expr should be error ...
In the past we discussed the out-of-bounds case and decided to make runtime evaluation consistent with evaluation at creation-time error.
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
I think the component developers should handle the property’s value could be
undefined
condition caused by a wrong expression or empty input and consider whether to provide a default value for the property or throw the errors.Displaying the error messages could help the Sunmao users fix some expression errors but can’t avoid them totally so I think we should handle the wrong expression in some ways.
Yes. When switching the JS mode, the expression string is hard to display by the other widgets. Thus, I think maybe set the property to the default value when switching the JS mode.
In addition, I think we should also remain the
exampleProperties
in the spec because thedefaultValue
is used to init or reset or be a fallback and theexampleProperties
is used to show the base usages of components when inserting the components.@tanbowensg
I think this is an issue of soundness.
What’s the expected behavior when a user writes a wrong expression like
{{ const a }}
and passes the schema to sunmao-ui’s runtime?Responses I’ve thought about:
defaultValue
, then log the error to consoleOf course, there may be some different ways to handle this in dev/production environments or in runtime/editor scope, but I think we can start from the specific one.