Sveltosis: Treat arrow functions as regular function declarations #1188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there!
This is a clumsy approach to treat arrow functions equal to regular function declarations.
I usually write my functions as arrow functions like so (as a matter of personal taste, I find it more readable):
Before this PR the generated code looked like this:
So the ArrowFunction was detected as VariableDeclaration, which is not wrong, but the generated code wouldn't work anyway.
Edit:
With this PR, the generated code looks like this(have to check that).It should keep the ArrowFunction as is. I'm running out of time for today :/
This is not perfect, but I created this PR to start the discussion. :)
Caveats
This might have some issues depending how the ArrowFunction was declared. E.g. if destructuring is involved, the code breaks very likely.
Fixes #1182