Files
datalive-design/src/schema/core/json-value.ts
T

25 lines
884 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* JSON 原生可序列化值 (Strict JSON Serializable Value)
*
* 【架构定位】:
*
* 它是低代码 Schema 抵御脏数据污染的“类型铁壁 (Type Barrier)”。
*
* 核心背景:
*
* 低代码的 `design-mode` 配置蓝图,最终宿命是调用 `JSON.stringify` 存入数据库。
* 如果在 Schema 的属性(如 `props`, `data`)中滥用 `any` 或 `object`
* 实施人员极易在配置中混入 `Function`, `Date`, `RegExp` 或类实例等非法对象,
* 这将导致序列化时数据丢失(变成死字符串或 undefined),引发毁灭性的页面崩溃。
*
* 此递归类型(Recursive Type)在 TypeScript 编译阶段,
* 就极其原教旨主义地封杀了所有非标准 JSON 类型的侵入。
*/
export type JsonValue =
| string
| number
| boolean
| null
| JsonValue[]
| { [key: string]: JsonValue };