The serialized form of a node as accepted by the parsing methods
(LexicalNode.importJSON and LexicalNode.updateFromJSON).
Only `type` identifies the node here: every node-specific property is made
optional via `Partial`. Parsing is generally untrusted and must tolerate
missing or out-of-domain values, so implementations are expected to
substitute sensible defaults — see the Parse helpers such as
stringValue, numberValue, and enumValue. This also
enables a "compact" serialization variant in which any property left at its
default is omitted.
The deprecated `version` is relaxed here rather than on
SerializedLexicalNode: a compact export omits it, but the legacy
form always writes it, and making it optional at the base would take that
promise away from the full output type as well.
type SerializedPartial<T extends SerializedLexicalNode> = Omit<SerializedLexicalNode & Partial<T>, '$slots' | 'children' | 'version'> & { /** * Slot values are parsed by the same rules, so they relax the same way — * and, like the parse entry point, name the declared form too: naming only * the indexed `SerializedPartialNode` meant a slot could not hold a value * whose type is a declared interface, since TypeScript gives an interface no * implicit index signature. */ $slots?: Record<string, SerializedPartialNode | SerializedLexicalNode>; /** Omitted by a compact export, like every other restorable property. */ version?: number; } & (T extends { children: readonly SerializedLexicalNode[]; } ? { /** * An element's children are nodes of the same document, written in the * same form, so they relax too: `Partial<T>` alone would make the array * optional while still promising that everything in it is fully * serialized, which is untrue of every compact element but the leaves. */ children?: SerializedPartialNode[]; } : unknown)
Import
import { SerializedPartial } from '@modular/sdk/editor';