Object.freeze on an array should result in a read-only array
Open
feature request
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Flow version: 0.98.1
## Expected behavior
Given this input:
```
const x = Object.freeze(['hello']);
x.push(1);
```
The `push` will fail at runtime. Flow should recognise that the array is read-only. I guess given an `Array` passed to `Object.freeze`, the result should be a `$ReadOnlyArray`
## Actual behavior
Flow does not flag any errors
TypeScript correctly flags this: `Property 'push' does not exist on type 'readonly string[]'.`
Link to Try-Flow: https://flow.org/try/#0MYewdgzgLgBAHjAvDA8gIwFYFNhQHQBmATllgF5YAUA2gOQAWWANkyLQLoCUA3AFBx4ADgFcI9SgEYeQA
Contributor guide
Assessment
This issue has not been assessed yet.