Thanks for posting this. I actually just spent the past 2 days reading through the Flow docs.
Eric Masiello

Mixed is a more strict version of Any.
Just like from the docs, Any allows any type pass through without errors, and it’s okay to use it, if you’re transitioning to using flow in your already exiting projects.

Here’s an example to demonstrate the difference:
Imagine we have an Object.

let x = {};
But somewhere in our code, we expect the Object to have a method, for example:
let x = {
y: () => “hello method”;

But our Object doesn’t come with a method, and yet we call the Object:

let x = {};
const callMethod: any = x;
callMethod.z() //using Any allows us get away with this by not throwing errors.

While using Mixed:

let x = {}
const recall: mixed = x;
recall.z(); //throws error cannot call method on recall

Mixed will not allow us call a method z on the recall variable.

A way to make this pass is:

let x = {
y: () => "over here!"
const recall: mixed = x.y();

If we also called the Object x on a non-existent method or property, it will also throw an error, for example:

let x = {};
const callMethod: mixed = x.z(); //we get an error of unknown property.

I hope this helps.

Like what you read? Give Jihdeh Stephens a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.