-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error for @render undefined
if snippet function is state
#12999
Comments
@render undefined
if snippet is state@render undefined
if snippet function is state
Is there a chance this can get looked at / added to the milestone? Fixing this would be a breaking change. |
To me it feels like we should do the opposite: just render nothing if |
This is a bug, |
Should it? Shouldn't we error if it's called but is undefined, similar to how you get a JS error when invoking |
Then case 1 above should also throw an exception? Either way it's a bug. |
How do we want to fix it? I already have a fix locally in case we want to always render nothing...throwing should also be pretty straightforward |
I'm torn. I know in other situations we are erring on the side of rendering nothing. I don't know whether we want to say that we should error here because the syntax looks like a function invocation. In a similar vein, if |
For me it's more about the look - it looks like a function call, and a function call would error if you'd call a falsy value. |
Agreed that we should not allow state of |
Turns out that making it a runtime error for state is a bit tricker than expected due to how we compile the dynamic logic out. @render optional?.() and also @render optional.() Becomes this when compiled: $.snippet(node_7, () => $$props.optional) So I'm actually leaning towards all nullish entries being rendered as empty instead. |
Can't the snippet function throw an error if it's undefined? |
That's my point, |
Oh gotcha...I mean I'm perfectly fine to render empty but we could also add a parameter to snippet passing true or false based on if the function call is with optional or not? |
What about? @render optional?.foo?.() or @render optional?.foo() What is the argument for those cases? |
Surely that's the thing we should be fixing? |
Roger that. |
Describe the bug
Currently, @render has no problem if it the snippet function is undefined if it's a state/prop, which is weird since it is a function call. Considering the
{@render func?.()
syntax is supported, it should throw.Case 1:
Case 2:
Severity
annoyance
The text was updated successfully, but these errors were encountered: