flow
flow copied to clipboard
Flow thinks "arguments" is an array?
Flow version: 0.137.0
Expected behavior
arguments is not exactly an array, and does not have function forEach.
Actual behavior
No warning for the following code:
function foo() {
arguments.forEach(() => {
});
}
- Link to Try-Flow or Github repo: https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVUCuA7AxgFwEs5swo44AKQgGjACs6BrASjAG9UwwBDAJwDmmALYBTbPgDOAOnJ8Aoj1wALSpTYBeAHwcuYAL4sA3Kn1A
Actually it's set to explicit any. You can do anything with it
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVUCuA7AxgFwEs5swo44AKQgGjACs6BrASjAG9UwwBDAJwDmmALYBTbPgDOAOgGj8AWVEBlOGIBq-Si1QBfIA
Oh, OK. Can this be fixed to be more specific?
It's defined here if you think it can be refined https://github.com/facebook/flow/blob/master/lib/core.js#L345
This is the ts declaration:
interface IArguments {
[index: number]: any;
length: number;
callee: Function;
}
Can it easily be translated to Flow?
https://github.com/microsoft/TypeScript/blob/master/lib/lib.es5.d.ts#L388-L392
Maybe something like this?
Maybe you can first change the core.js locally to see if it works better, and then maybe check with others on discord to see if it's appropriate to make this change. I think this works but I'm not confident 😅
Yeah, I can check. Thanks!