Skip to main content

ParsableSerializedNode

type

The least a value has to be for $parseSerializedNode to read it: a `type` to look the class up by, and subtrees of the same shape. A type alias rather than an `interface`, which is what lets it stand in for the internal shape the parse walks: TypeScript gives an alias an implicit index signature and an interface none, and the walk's own parameter carries one. An interface is still assignable *to* it, which is the direction that matters for a caller like `@lexical/clipboard`'s `BaseSerializedNode`. `version` is optional because the parser drops it — it is deprecated and nothing reads it — so requiring it described the caller rather than the parameter. That mattered because SerializedPartialNode carries an index signature, which an `interface` never satisfies, and SerializedLexicalNode requires `version`: a caller holding an interface with an optional `version`, such as `@lexical/clipboard`'s `BaseSerializedNode`, matched neither, and the mismatch repeated at every level because `children` and `$slots` recurse.

type ParsableSerializedNode = { /** A slot holds a node subtree, so it relaxes exactly as `children` do. */ $slots?: Record<string, ParsableSerializedNode>; /** Present when the node is an element; the same form all the way down. */ children?: ParsableSerializedNode[]; /** The one property every node carries and a reader narrows by. */ type: string; /** * @deprecated Dropped when parsing; see {@link SerializedLexicalNode.version}. */ version?: number; }

Import

import { ParsableSerializedNode } from '@modular/sdk/editor';