What is the difference between `mixed` and `any`?

flow mixed typescript
flow any type
flow any function
flow type rest parameters
flow cast mixed
number is incompatible with mixed
flow property is missing in mixed
flow default arguments

The docs say:

  • mixed: the "supertype" of all types. Any type can flow into a mixed.
  • any: the "dynamic" type. Any type can flow into any, 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.

Flow tips and tricks, part 1: mixed and any - NGUYEN Trung, Typing unknown types with mixed. In general, programs have several different categories of types: A single type: mixed will accept any type of value. Strings  I'll concentrate on Mixed Platform and how this different from Any CPU. The Any CPU is at the project level setting, where as in real world solution we have number of projects under one solution, and their are chances that some of my project use Any CPU , but others uses the x86 or x64 build platform.

"Any" supports covariance and contravariance. That's because "any" is a super-type and a subtype of all types.

Hence this works,

let genericVariable: any = 20;
let numericVariable: number;

genericVariable = numericVariable; // No error
numericVariable = genericVariable; // No error

mixed supports covariance only. It's a super-type and not a sub type of all types.

let genericVariable: mixed = 20;
let numericVariable: number;

numericVariable = genericVariable; // This shows error
genericVariable = numericVariable; // This works fine.

Covariance - Generic type (parent) could be substituted by special type (child)

Contravariance - Special type (child) could be substituted by Generic type (parent). This is a problem, unless protected by certain conventions.

Mixed Types, Opting out of the type system with any. Search docs. Warning: Do not mistake any with mixed . For example, the following code will not report any errors:  The difference between an independent ANOVA and a mixed-design ANOVA is based on the number of times your dependent variable (DV) is measured per subject (participants in my case as I measure people).

When flow sees any that means you can use any type. The program is indifferent as to the parameter's type, and it will not try to infer result type. So result type will be any also.

For example, the following code will not report any errors:

// @flow
function add(one: any, two: any): number {
  return one + two;

add(1, 2);     // Works.
add("1", "2"); // Works.
add({}, []);   // Works.

But "mixed" type should be processed someway to infer actual type.

// @flow
function stringify(value: mixed) {
  // $ExpectError
  return "" + value; // Error!


Instead you must ensure the value is a certain type by refining it.

// @flow
function stringify(value: mixed) {
  if (typeof value === 'string') {
    return "" + value; // Works!
  } else {
    return "";


Any Types, Looking for clinical correlates they found no differences in number of mixed states in patients with and without early adverse experiences. They also found no​  To cut a long story short, here’s the difference between virtual, augmented, and mixed reality technologies: Virtual reality (VR) immerses users in a fully artificial digital environment.

Mixed Affective States: Beyond Current Boundaries, An Issue of , Any alterations in the Constitution may be taken into consideration provided (if indeed there ever be any difference between these two things) refused to free  The difference between mixed cropping and intercropping are described in the points given below: When two or more crops are sown and cultivated at the same time in the particular area, then this type of cropping pattern is known as mixed cropping.

Of democracy. Mixed monarchy, They worked under examination conditions, with no staff present, and their attitude Taking the classes separately none of the differences between mixed and  What is the difference between what we have been calling VR on the PC, and Microsoft’s Windows Mixed Reality (WMR)? VR’s Main Players: Oculus Rift and HTC Vive The two heavies when it comes to VR on a PC are the Oculus Rift and HTC Vive.

Mixed or Single-sex School? Volume 2: Some Social Aspects, Moreover, there are large differences between mixed valence pairs of different oxidation states. For the MnHIMn'V dimer one expects to see one hf constant  Really there isn't a difference. They're both mixed. The only difference is at one time the mixing occurred. Some people consider someone to be mixed, if they can actually tell by looking at them,