Three decisions that make the output usable
Array elements are merged, not sampled. A generator that types an array from its first element produces a model missing every field that element happened to lack. Every element is unified here instead, and a field absent from some of them becomes optional - which is almost always the truth about the API that produced the sample.
Identical shapes are shared. An object with a from and a to carrying the same fields produces one type used twice, not two identical declarations under different names. Structural identity is decided on the field list and the field types, so the output stays as small as the data actually is.
Nullable and optional are different facts. Optional means the key was absent from some element; nullable means it was present and its value was null. A field that is always there and sometimes null is a nullable string, not a required one. Conflating the two produces a model that type-checks and then throws on the first null, and it is the commonest defect in generators of this kind.