-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
instanceof Array refinement adds Array<any> to type #6874
Comments
This looks related to #6741, likely the same bug. |
I think this is related to an issue I'm having with
By itself,
Just running the method causes flow to add the Tested with Flow 0.93. |
@mgreenw: That's not related. Feel free to open a separate issue. |
Closing because this appears to have been fixed as of v0.97.0. |
https://flow.org/try/#0PTACDMBsHsHcCh4BMCmBjSBDATigBBpgM5F4DC0M2eA3vHnkQC6ZMCWaeA1ACraYA7IgAccKAUwBc5StGwBueAF9ETAJ7D8ABWzRhpALy16eAEZzU2ClQD8063LwAfPAEFs-NQB4H2AHwANCbm2JYA6mxITAAWdngCAK4AtqYo1C7unl6JKWl+yorwaNBCTGYWaUQ8KMxkxPhGABTCuvrSOnpEAJR4Bn7GDJAoZSGWvtKZmN6+-UYA2gC6hQxs4HjNrUQAdKNpvj10DCtrG507FVay1Gylgmgo0GuTagcmR+Whe1e9eC1nu5cqIp3ko8ChIER8Id3h8xt8jAIULA3B4po0ACxdLbgNiQSCnfTnT6AuRdYFHFQMUHgyEDI4A3w-RHI54YrE4vGNXxbPiCERiCRkkwqExDEYXCJRaITVHeHKpfw-RbLPCrdZ-QkAyUxV7vNUE7ZayIxVW3AT3R4ozy6mFGqU-DWGiXG6LkqlgiFQt70532hFIq1ozHY3H4x1E8IuoUg4Ue2nQhh2k3+lmytkhzkABmjeBUSkUQA
This case demonstrates the same code structure working with two different types:
void | number | Array<number>
andvoid | Color | Array<Color>
.Flow chokes on the code dealing with the
Color
class. Inspecting what flow thinks the types are using the vscode plugin, it shows that on line 15, the type is correct:void | Color | Array<Color>
. On line 16, it is correct:Color | Array<Color>
. On line 17, after theinstanceof Array
check, it suddenly becomesArray<Color> | Array<any>
, which is incompatible with theArray<Color>
variable I'm trying to assign it to.This doesn't happen for the
number
case - after theinstanceof Array
check, it correctly infers that the type is onlyArray<number>
.Where is this
Array<any>
coming from?If I use
Array.isArray
instead ofinstanceof Array
, it type checks correctly.The text was updated successfully, but these errors were encountered: