Skip to content

[lexical-website] Documentation Update: fix two nodes.mdx snippets that do not compile - #9200

Merged
etrepum merged 2 commits into
meta:mainfrom
potatowagon:docs-nodes-snippet-types
Sep 23, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
potatowagon:docs-nodes-snippet-types

Conversation

@potatowagon

Copy link
Copy Markdown
Contributor

Description

Two TypeScript snippets in concepts/nodes.mdx cannot be compiled as written:

  1. The custom-node serialization example declares
    interface SerializedCustomNode, but every use of it in the same snippet —
    the importJSON and updateFromJSON parameter types and the exportJSON
    return type — says SerializedMyCustomNode. The declared name is never
    referenced and the referenced name is never declared.
  2. Both ColoredNode examples annotate their constructor with a return type:
    constructor(..., key?: NodeKey): void {. A TypeScript constructor cannot
    carry a return-type annotation (TS1093); this is a leftover from the Flow
    era. No constructor in the repo's own node classes has one.

This renames the interface to match its uses and drops the two : void
annotations. No prose changes.

Test plan

Documentation-only change (markdown is excluded from prettier via
.prettierignore), so the check is that the snippets are now valid TypeScript.

Before

$ grep -n "SerializedCustomNode\|SerializedMyCustomNode" packages/lexical-website/docs/concepts/nodes.mdx
145:interface SerializedCustomNode extends SerializedLexicalNode {
163:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
174:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
182:  exportJSON(): SerializedMyCustomNode {
183:    const serializedNode: SerializedMyCustomNode = super.exportJSON();

$ grep -n "): void {" packages/lexical-website/docs/concepts/nodes.mdx
572:  ): void {
934:  constructor(text: string, color: string, key?: NodeKey): void {

SerializedMyCustomNode is undeclared, and both constructors are TS1093
("Type annotation cannot appear on a constructor declaration").

After

$ grep -n "SerializedCustomNode\|SerializedMyCustomNode" packages/lexical-website/docs/concepts/nodes.mdx
145:interface SerializedMyCustomNode extends SerializedLexicalNode {
163:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
174:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
182:  exportJSON(): SerializedMyCustomNode {
183:    const serializedNode: SerializedMyCustomNode = super.exportJSON();

$ grep -n "): void {" packages/lexical-website/docs/concepts/nodes.mdx
$ grep -n "constructor(text: string, color" packages/lexical-website/docs/concepts/nodes.mdx
934:  constructor(text: string, color: string, key?: NodeKey) {

The interface name now matches its five uses, and neither constructor carries a
return type — matching the node classes in packages/lexical/src/nodes/.

…at do not compile

## Description

Two TypeScript snippets in `concepts/nodes.mdx` cannot be compiled as written:

1. The custom-node serialization example declares
   `interface SerializedCustomNode`, but every use of it in the same snippet —
   the `importJSON` and `updateFromJSON` parameter types and the `exportJSON`
   return type — says `SerializedMyCustomNode`. The declared name is never
   referenced and the referenced name is never declared.
2. Both `ColoredNode` examples annotate their constructor with a return type:
   `constructor(..., key?: NodeKey): void {`. A TypeScript constructor cannot
   carry a return-type annotation (`TS1093`); this is a leftover from the Flow
   era. No constructor in the repo's own node classes has one.

This renames the interface to match its uses and drops the two `: void`
annotations. No prose changes.

## Test plan

Documentation-only change (markdown is excluded from prettier via
`.prettierignore`), so the check is that the snippets are now valid TypeScript.

### Before

```
$ grep -n "SerializedCustomNode\|SerializedMyCustomNode" packages/lexical-website/docs/concepts/nodes.mdx
145:interface SerializedCustomNode extends SerializedLexicalNode {
163:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
174:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
182:  exportJSON(): SerializedMyCustomNode {
183:    const serializedNode: SerializedMyCustomNode = super.exportJSON();

$ grep -n "): void {" packages/lexical-website/docs/concepts/nodes.mdx
572:  ): void {
934:  constructor(text: string, color: string, key?: NodeKey): void {
```

`SerializedMyCustomNode` is undeclared, and both constructors are `TS1093`
("Type annotation cannot appear on a constructor declaration").

### After

```
$ grep -n "SerializedCustomNode\|SerializedMyCustomNode" packages/lexical-website/docs/concepts/nodes.mdx
145:interface SerializedMyCustomNode extends SerializedLexicalNode {
163:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
174:    serializedNode: LexicalUpdateJSON<SerializedMyCustomNode>,
182:  exportJSON(): SerializedMyCustomNode {
183:    const serializedNode: SerializedMyCustomNode = super.exportJSON();

$ grep -n "): void {" packages/lexical-website/docs/concepts/nodes.mdx
$ grep -n "constructor(text: string, color" packages/lexical-website/docs/concepts/nodes.mdx
934:  constructor(text: string, color: string, key?: NodeKey) {
```

The interface name now matches its five uses, and neither constructor carries a
return type — matching the node classes in `packages/lexical/src/nodes/`.
@vercel

vercel Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 23, 2026 5:57pm UTC
lexical-playground Ready Ready Preview Sep 23, 2026 5:57pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 23, 2026

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a prettier ci-check failure here, and maybe opening separate PRs for the same file is not ideal since they may conflict

…uctor for prettier

## Description

Follow-up to the parent commit, which dropped the invalid `: void` return
annotations from the two `ColoredNode` constructors. Removing ` : void` made
the first constructor's parameter list fit on one 80-column line, so prettier
now wants it collapsed rather than split across four lines. `.mdx` is not in
`.prettierignore` (only `**/*.md` is), so `pnpm run ci-check` fails on it.

No content change — purely the formatter's line break.

## Test plan

### Before

```
$ npx prettier --check packages/lexical-website/docs/concepts/nodes.mdx
Checking formatting...
[warn] packages/lexical-website/docs/concepts/nodes.mdx
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
```

### After

```
$ npx prettier --check packages/lexical-website/docs/concepts/nodes.mdx
Checking formatting...
All matched files use Prettier code style!

$ sed -n '568p' packages/lexical-website/docs/concepts/nodes.mdx | awk '{print length($0)}'
80
```
@etrepum
etrepum added this pull request to the merge queue Sep 23, 2026
Merged via the queue into meta:main with commit ab1c252 Sep 23, 2026
42 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 3d9791c2 Deployed Sep 23, 2026 by vercel[bot]
Preview – lexical-playground — 3d9791c2 Deployed Sep 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants