Skip to content

Commit

Permalink
[compiler] Add repro for outlining in non VarDecls
Browse files Browse the repository at this point in the history
ghstack-source-id: 7688987b0277113f4006ecaf343863d9fb30f83b
Pull Request resolved: #30465
  • Loading branch information
poteto committed Jul 25, 2024
1 parent 88bf4e1 commit d529a43
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

## Input

```javascript
function Component(props) {
return <View {...props} />;
}

const View = React.memo(({items}) => {
return (
<ul>
{items.map(item => (
<li key={item.id}>{item.name}</li>
))}
</ul>
);
});

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [
{
items: [
{id: 2, name: 'foo'},
{id: 3, name: 'bar'},
],
},
],
};

```


## Error

```
3 | }
4 |
> 5 | const View = React.memo(({items}) => {
| ^^^^^^^^^^^^^^
> 6 | return (
| ^^^^^^^^^^
> 7 | <ul>
| ^^^^^^^^^^
> 8 | {items.map(item => (
| ^^^^^^^^^^
> 9 | <li key={item.id}>{item.name}</li>
| ^^^^^^^^^^
> 10 | ))}
| ^^^^^^^^^^
> 11 | </ul>
| ^^^^^^^^^^
> 12 | );
| ^^^^^^^^^^
> 13 | });
| ^^ Invariant: Expected a variable declarator parent (5:13)
14 |
15 | export const FIXTURE_ENTRYPOINT = {
16 | fn: Component,
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function Component(props) {
return <View {...props} />;
}

const View = React.memo(({items}) => {
return (
<ul>
{items.map(item => (
<li key={item.id}>{item.name}</li>
))}
</ul>
);
});

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [
{
items: [
{id: 2, name: 'foo'},
{id: 3, name: 'bar'},
],
},
],
};

0 comments on commit d529a43

Please sign in to comment.