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
/* */
comments don't work in inline functions
#7456
Comments
/*
comments don't work in inline functions
/*
comments don't work in inline functions/* */
comments don't work in inline functions
I'm not saying this should or shouldn't work, but the comment is not inside your function. It works inside the function, e.g. <button on:click="{() => {/* asdf */}}" /> I'm not an expert on the Svelte syntax definition, but to me everything inside the outer curly brackets needs to be a single JavaScript expression. And comments are not part of the JavaScript expression. So what you've posted is the same as doing this: <script>
let name = 'world';
</script>
<h1>Hello {name /* asdf */}!</h1> which equally doesn't work. The docs always talk about "JavaScript expressions" when talking about what comes inside the curly brackets. And comments aren't expressions. |
the way i see it comments should have no impact on the code whatsoever. so if an expression has a comment after it, it should still be considered an expression |
So you thing: <input type="number /* this is input for age */ ">hello</input> should work too? Actually you can't put comment everywhere in HTML or JS too... like in middle of regex or attribute... So I disagree that "you can put comment everywhere"... but I actually agree that having ability to add comments inside expressions would be nice. |
@Mlocik97 In your example that is not a Javascript context expression, so a javascript comment should not work, so... Some flavors of regex supports comments: regex comments html supports comments: <input input="number /* this is input for age */ "><!--this is a comment-->hello</input> The comment is not stating that Javascript comment syntax should work in every possible context, it's only stating that it should be valid for expressions to be able to be prepended/appended with comments. |
yeah, you put that HTML comment outside of attribute value... so tell me... <input type="number <!-- doesn't work either -->">hello</input> I didn't said it's expression, but I'm just arguing against "you can put comment everywhere", or resp. "the way i see it comments should have no impact on the code whatsoever.", even tho it has nothing to do if it's allowed at specific place such as expression. Another possible way is put IIFE in expression, and pass comments inside it. As it was already mentoyed here. Still I'm ofc for this feature request. |
By "comments should have no impact on the code" I didn't mean html comments should work in JavaScript or anything like that, all I meant is that whether or not some JavaScript code is considered a valid expression shouldn't be effected by whether or not there's a valid JavaScript comment in the code. just linke in plain html: <!-- no error -->
<button onclick="foo() /*asdf*/">asdf</button> |
I was not talking about it as well... |
What is the use-case for needing a comment inside of an inline function? What problem does that solve? |
Describe the bug
"Expected }" syntax error when attempting to use
/*
commentsReproduction
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: