Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi committed Oct 28, 2024
1 parent abd36cb commit 68bb625
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/core/src/parsers/jsx/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ const processStateObjectSlice = (item: ObjectMethod | ObjectProperty): StateValu
type: 'function',
};
} else if (isArrowFunctionExpression(item.value)) {
/**
* Arrow functions are normally converted to object methods to work around
* limitations with arrow functions in state in frameworks such as Svelte.
* However, this conversion does not work for async arrow functions due to
* how we handle parsing in `handleErrorOrExpression` for parsing
* expressions. That code does not detect async functions in order to apply
* its parsing workarounds. Even if it did, it does not consider async code
* when prefixing with "function". This would result in "function async foo()"
* which is not a valid function expression definition.
*/
if (item.value.async) {
const func = functionExpression(
item.key as Identifier,
Expand Down

0 comments on commit 68bb625

Please sign in to comment.