🌊 JSON 转 Flow 类型JSON to Flow Types
根据 JSON 生成 Flow 静态类型定义(export type):支持精确对象类型 {| |}、只读属性、可选键与 ?T 可空类型,嵌套对象生成独立类型。Generate Flow type aliases (export type) from JSON: exact object types {| |}, read-only properties, optional keys and ?T maybe types, with a separate type for each nested object.
使用说明与常见问题How-to & FAQ
「JSON 转 Flow 类型」是什么?What is the JSON to Flow Types tool?
根据 JSON 生成 Flow 静态类型定义(export type):支持精确对象类型 {| |}、只读属性、可选键与 ?T 可空类型,嵌套对象生成独立类型。Generate Flow type aliases (export type) from JSON: exact object types {| |}, read-only properties, optional keys and ?T maybe types, with a separate type for each nested object.
如何使用「JSON 转 Flow 类型」?How do I use the JSON to Flow Types?
粘贴 JSON 并填写根类型名,下方生成带 // @flow 注释的类型定义,复制到 .js 文件中即可使用。Paste JSON and set the root type name to get type definitions with the // @flow header, ready for your .js files.
key?: T 和 key: ?T 有什么区别?key?: T vs key: ?T?
key?: T 表示这个键可以不存在;key: ?T 表示键一定存在,但值可以是 null 或 undefined。工具会根据样本中字段是否缺失、是否为 null 自动选择。key?: T means the key may be absent; key: ?T means it is present but the value may be null or undefined. The tool picks based on whether the sample omits the key or has null.
生成的代码适用于哪个版本的 Flow?Which Flow version is this for?
默认输出新版 Flow 的写法(unknown、readonly,对象类型默认精确),已用 Flow 0.337 检查通过。老项目可以勾选「兼容旧版 Flow」改用 mixed 和 + 只读标记,或勾选显式精确对象 {| |}。By default it uses modern Flow syntax (unknown, readonly, exact-by-default objects) and was checked with Flow 0.337. For older projects tick “Legacy Flow syntax” for mixed and the + variance sigil, or tick explicit exact objects {| |}.
「JSON 转 Flow 类型」免费吗?数据会上传吗?Is the JSON to Flow Types free? Is my data uploaded?
「JSON 转 Flow 类型」完全免费,无需注册或安装,手机和电脑都能用;所有处理都在你的浏览器本地完成,输入的内容和文件不会上传到服务器。The JSON to Flow Types is completely free with no sign-up or install and works on phones and desktops; everything runs locally in your browser and nothing you enter is uploaded.