The docs say:
mixed
: the "supertype" of all types. Any type can flow into amixed
.any
: the "dynamic" type. Any type can flow intoany
, and vice-versa
What would be a case where mixed
and any
cannot be used interchangeably?
The difference is the "vice-versa": any
can flow into other types but mixed
can not.
/* @flow */
var numeric:number = 0;
var looselyTyped:any;
var someType:mixed;
numeric = looselyTyped;
numeric = someType; //only this will throw a flow check error
From the docs you linked to:
It is worth calling out any specifically because of the special nature of this annotation. Use any to escape the static typing of Flow. In other words, if Flow is getting in your way, and you are absolutely convinced your program is type correct, you can silence the errors by annotating locations along the error paths with type any.