-
Notifications
You must be signed in to change notification settings - Fork 47.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler: Add todo for getter/setter syntax
We were missing a check that ObjectMethods are not getters or setters. In our experience this is pretty rare within React components and hooks themselves, so let's start with a todo. Closes #29586 [ghstack-poisoned]
- Loading branch information
1 parent
a15a43e
commit 9bd33c9
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...c/__tests__/fixtures/compiler/error.todo-object-expression-get-syntax.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
function Component({ value }) { | ||
const object = { | ||
get value() { | ||
return value; | ||
}, | ||
}; | ||
return <div>{object.value}</div>; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: foo, | ||
params: [{ value: 0 }], | ||
sequentialRenders: [{ value: 1 }, { value: 2 }], | ||
}; | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
1 | function Component({ value }) { | ||
2 | const object = { | ||
> 3 | get value() { | ||
| ^^^^^^^^^^^^^ | ||
> 4 | return value; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
> 5 | }, | ||
| ^^^^^^ Todo: (BuildHIR::lowerExpression) Handle get functions in ObjectExpression (3:5) | ||
6 | }; | ||
7 | return <div>{object.value}</div>; | ||
8 | } | ||
``` | ||
14 changes: 14 additions & 0 deletions
14
...react-compiler/src/__tests__/fixtures/compiler/error.todo-object-expression-get-syntax.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function Component({ value }) { | ||
const object = { | ||
get value() { | ||
return value; | ||
}, | ||
}; | ||
return <div>{object.value}</div>; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: foo, | ||
params: [{ value: 0 }], | ||
sequentialRenders: [{ value: 1 }, { value: 2 }], | ||
}; |
41 changes: 41 additions & 0 deletions
41
...c/__tests__/fixtures/compiler/error.todo-object-expression-set-syntax.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
function Component(props) { | ||
let value; | ||
const object = { | ||
set value(v) { | ||
value = v; | ||
}, | ||
}; | ||
object.value = props.value; | ||
return <div>{value}</div>; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: foo, | ||
params: [{ value: 0 }], | ||
sequentialRenders: [{ value: 1 }, { value: 2 }], | ||
}; | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
2 | let value; | ||
3 | const object = { | ||
> 4 | set value(v) { | ||
| ^^^^^^^^^^^^^^ | ||
> 5 | value = v; | ||
| ^^^^^^^^^^^^^^^^ | ||
> 6 | }, | ||
| ^^^^^^ Todo: (BuildHIR::lowerExpression) Handle set functions in ObjectExpression (4:6) | ||
7 | }; | ||
8 | object.value = props.value; | ||
9 | return <div>{value}</div>; | ||
``` | ||
16 changes: 16 additions & 0 deletions
16
...react-compiler/src/__tests__/fixtures/compiler/error.todo-object-expression-set-syntax.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function Component(props) { | ||
let value; | ||
const object = { | ||
set value(v) { | ||
value = v; | ||
}, | ||
}; | ||
object.value = props.value; | ||
return <div>{value}</div>; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: foo, | ||
params: [{ value: 0 }], | ||
sequentialRenders: [{ value: 1 }, { value: 2 }], | ||
}; |