Are Flow types still relevant in 2026?
Yes, in specific contexts. TypeScript dominates the broader ecosystem, but Meta still uses Flow internally across their massive React/React Native monorepos and ships open-source projects (Relay, Recoil, Hermes) with Flow type annotations. Flow has features TypeScript still does not (true exact object types via {|...|}, structural variance opt-in, opaque types). If you maintain code that targets Meta-aligned tooling or want stricter object shape checks, Flow remains a sensible choice.
Why exact object types ({|...|}) instead of regular ({...}) ?
Exact object types in Flow forbid extra properties at type-check time, matching XML semantics where a known schema means "these fields and only these fields". Regular {...} permits unknown extras, which is too loose for XML round-tripping. The generator emits exact types by default — drop the |s if you genuinely need width subtyping.
How are XML attributes typed in Flow?
XML attributes become @_-prefixed string fields inside the type alias — matching the convention fast-xml-parser uses when it converts XML to JSON. Because @ is not a valid JavaScript identifier the key is wrapped in single quotes, e.g. quoted-attr-id colon string. Flow treats quoted keys identically to bare keys for type checking.
How are repeated elements typed?
Repeated child elements become Array<T> with T inferred from the first occurrence. Flow has both Array<T> and $ReadOnlyArray<T>; the generator picks the mutable variant. Switch to $ReadOnlyArray if your component only reads from the array — the stricter type catches accidental mutations at type-check time.
How does Flow compare to TypeScript for XML data?
TypeScript has a far larger community, more libraries with built-in types, and IDE tooling that ships out of the box. Flow has true exact types, opaque types, and tighter inference for React props. Both compile away cleanly — neither adds runtime cost. If your project already uses Flow, this generator slots in; if you are starting fresh, our XML to TypeScript generator is the more conventional choice.
Does the type include optional fields?
No. Required-vs-optional cannot be inferred from a single XML sample (the example you paste might be a maximal instance). Append a question mark to any field key you know is optional, e.g. lang?: string, and Flow will permit it being absent. The generator deliberately stays neutral.
Is the XML I paste sent to your servers?
No. XML is parsed by the browser DOMParser and the Flow type source is generated entirely in JavaScript on your machine. Open DevTools → Network and you will see no requests when you click Convert. Safe for SOAP responses and configuration files containing API keys or credentials.
How do I use the generated type with a fast-xml-parser result?
Cast the parser output: const data: { book: Book } = (parser.parse(xml): any); — the colon-cast brings the type checker on board. Flow will then enforce that downstream code respects the @_id, title, etc. fields. For stricter parses use the tagValueProcessor option of the parser to coerce numeric strings before casting.