What's the difference between intersection type and object type with same properties

 
Question:
 
What's the observable difference between the types
{ f1: number; f2: string; }
and
{ f1: number; } & { f2: string; }
If they're functionally the same, could the latter one just be reduced to the former one? I've found the feature to be of great use for sort of extensible records but my types get needlessly big when I append to them.
Answer:
There shouldn't be any semantic differences between the two. However, from a compiler performance point of view, an intersection type made up of many small object types definitely adds more computational load than a single large object type. And, as you point out, the intersection gets messier to look at in error messages and hints. The compiler doesn't attempt to reduce intersection types because it involves analysis and detection of circularly dependent types and can't be done fully when generics and type parameters are involved. We could potentially do something in simple cases, but I'm not sure the effort is worth it.
 
badge