Imported key in computed property results in lack of error detection
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
As you can see in the REPL example, Flow detects the lack of definition in the `state` accessed property only when the computed key is a locally defined variable. Isn't this a bug?
```js
/* @flow */
import { IMPORTED_ACTION } from 'imports'
const LOCAL_ACTION = 'ACTION'
type Action = { type: string, payload: Object }
type Handler = {
[key: string]: (state: T, action: $Subtype) => T
}
type MyState = {
items: Array
}
const handler: Handler = {
[IMPORTED_ACTION]: (state, action: Action) => ({
...state,
items: state.items.concat(action.payload.id),
test: state.test
}),
[LOCAL_ACTION]: (state, action: Action) => ({
...state,
items: state.items.concat(action.payload.id),
test: state.test
}),
}
```
```sh
22: test: state.test
^ property `test`. Property not found in
22: test: state.test
^ object type
```
[REPL Example](https://flowtype.org/try/#0PQKgBAAgZgNg9gdzCYAoAlgWwA5wE4AuYA3mAJICyACgPIBKAKgKIAiA+gIIDCDZNAcmAC+YKHjiYwAciy5CAZymoAxnAB28ogBkaXDls48+ggLzTuvAUtQEAntgCmYDsoLp1YM6TuOAXGE08dDUAcwAaMGwAQ1t4KIATfxoAIwArB1dhG3snAAkotXiYBzwAHgYAPk8SVDAwAG0Aawdbf0DgkIBdfwAKTSiCB38GCKjXdzV-ABIAZQBXZJ8HUpc3dQqASk8qhlQhbMcwClsZggGnL1qwdEHMeX8OPDwY0rU5zGSSir3UFXVNMAACwKRRK-nyhWKZWOp3OVUudXqlFojFYhks-G6YD6Z0Go3G6geBLUWxMVR6xCudQAdLT+niqddbvcAriHNSbg47tTVGplAMemM1mpqdFYnAEhz4hswozBpo2mzqfKCFchDKrvUdHoDBZjFiced8cKicLSeTKXUaXS2bKrUyuSz6ezOdzefyCILiaKYnF4lKNfaVYrzsqHJo1Rr9kA)
Contributor guide
Assessment
This issue has not been assessed yet.