Skip to content

[lexical-y] Chore: Type SUPPORTED_YJS_VERSION as a string, and keep the playground's @y/y pin in step - #9615

Merged
zurfyx merged 1 commit into
mainfrom
zurfyx/y-yjs-guard-followup
Oct 30, 2026
Merged

zurfyx merged 1 commit into
mainfrom
zurfyx/y-yjs-guard-followup

Conversation

@zurfyx

@zurfyx zurfyx commented Oct 30, 2026

Copy link
Copy Markdown
Member

Description

Follow-ups to #9607 from the review bot:

  • SUPPORTED_YJS_VERSION was published as a literal type
    (export declare const SUPPORTED_YJS_VERSION = "14.0.0-rc.29"), so its
    TypeScript type changed with every @y/y bump, while the Flow
    declaration says string. It is now declared string, as
    LEXICAL_VERSION is; scripts/updateVersion.mjs matches the new form
    when it regenerates the literal.
  • The playground pins @y/y on its own (packages/lexical-playground),
    and nothing in the workspace ties it to @lexical/y's pin, so a bump
    that missed it would leave the playground's document and its provider on
    two copies of Yjs. The README's "Bumping @y/y" checklist names it, and
    YjsContract.test.ts now fails when the playground's pin differs from
    SUPPORTED_YJS_VERSION.

Changeset

None: SUPPORTED_YJS_VERSION keeps its value and is part of the unreleased
feature #9607's changeset already describes; the rest is docs, a test and
tooling.

Test plan

Before

The emitted declaration:

export declare const SUPPORTED_YJS_VERSION = "14.0.0-rc.29";

The new assertion with the playground's pin set to 14.0.0-rc.28:

× is the exact @y/y peer dependency, the dev dependency and the installed @y/y
AssertionError: expected '14.0.0-rc.28' to be '14.0.0-rc.29'

After

export declare const SUPPORTED_YJS_VERSION: string;
$ node scripts/updateVersion.mjs   # literal set to '0.0.0-stale' first
export const SUPPORTED_YJS_VERSION: string = '14.0.0-rc.29';

$ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/YjsContract.test.ts packages/lexical-y/src/__tests__/unit/Source.test.ts
      Tests  45 passed (45)

$ pnpm run ci-check
Changeset check passed: 53 pending changeset(s) valid.
Found 0 errors   (flow; tsc, prettier, lint clean)

…he playground's @y/y pin in step

## Description

Follow-ups to #9607 from the review bot:

- `SUPPORTED_YJS_VERSION` was published as a literal type
  (`export declare const SUPPORTED_YJS_VERSION = "14.0.0-rc.29"`), so its
  TypeScript type changed with every `@y/y` bump, while the Flow
  declaration says `string`. It is now declared `string`, as
  `LEXICAL_VERSION` is; `scripts/updateVersion.mjs` matches the new form
  when it regenerates the literal.
- The playground pins `@y/y` on its own (`packages/lexical-playground`),
  and nothing in the workspace ties it to `@lexical/y`'s pin, so a bump
  that missed it would leave the playground's document and its provider on
  two copies of Yjs. The README's "Bumping `@y/y`" checklist names it, and
  `YjsContract.test.ts` now fails when the playground's pin differs from
  `SUPPORTED_YJS_VERSION`.

## Changeset

None: `SUPPORTED_YJS_VERSION` keeps its value and is part of the unreleased
feature #9607's changeset already describes; the rest is docs, a test and
tooling.

## Test plan

### Before

The emitted declaration:

```
export declare const SUPPORTED_YJS_VERSION = "14.0.0-rc.29";
```

The new assertion with the playground's pin set to `14.0.0-rc.28`:

```
× is the exact @y/y peer dependency, the dev dependency and the installed @y/y
AssertionError: expected '14.0.0-rc.28' to be '14.0.0-rc.29'
```

### After

```
export declare const SUPPORTED_YJS_VERSION: string;
```

```
$ node scripts/updateVersion.mjs   # literal set to '0.0.0-stale' first
export const SUPPORTED_YJS_VERSION: string = '14.0.0-rc.29';

$ pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/YjsContract.test.ts packages/lexical-y/src/__tests__/unit/Source.test.ts
      Tests  45 passed (45)

$ pnpm run ci-check
Changeset check passed: 53 pending changeset(s) valid.
Found 0 errors   (flow; tsc, prettier, lint clean)
```
@vercel

vercel Bot commented Oct 30, 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 Oct 30, 2026 9:35pm UTC
lexical-playground Ready Ready Preview Oct 30, 2026 9:35pm 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 Oct 30, 2026
@meta-code-review

meta-code-review Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 30, 2026, 9:55 PM UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9615

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9615

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9615

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9615

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9615

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9615

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9615

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9615

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9615

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9615

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9615

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9615

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9615

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9615

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9615

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9615

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9615

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9615

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9615

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9615

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9615

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9615

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9615

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9615

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9615

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9615

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9615

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9615

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9615

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9615

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9615

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9615

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9615

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9615

@lexical/y

npm i https://pkg.pr.new/@lexical/y@9615

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9615

commit: 874806a

@meta-code-review meta-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks good to me, thanks! Annotating SUPPORTED_YJS_VERSION as string keeps its published TypeScript type stable across @y/y bumps and in line with flow/LexicalY.js.flow, the built JavaScript is unchanged, and the new assertion in YjsContract.test.ts fails exactly when the playground's @y/y pin drifts from @lexical/y's, the two-copies case the README now calls out.

Two optional, non-blocking notes:

  1. Changesets warning. The Changesets job flags packages/lexical-y/src/internal/SupportedYjs.ts as published code without a changeset. SUPPORTED_YJS_VERSION first ships with #9607's pending changeset, which already announces it, so a maintainer adding the skip-changeset label fits better than a new entry (CONTRIBUTING.md, "Changesets").
  2. scripts/updateVersion.mjs, lines 136-146 (nit). regenerateSupportedYjsVersion writes the module whether or not its pattern matched, so a future change to the declaration's form would turn pnpm run update-version into a silent no-op (the previous pattern does exactly that against the new annotated form), and the hint in YjsContract.test.ts would then point at a command that changes nothing. Throwing when the pattern finds no match would surface it right there. This predates the pull request, so a follow-up is fine.

Comment thread scripts/updateVersion.mjs
.readFileSync(modulePath, 'utf8')
.replace(
/(export const SUPPORTED_YJS_VERSION = )'[^']*'/,
/(export const SUPPORTED_YJS_VERSION: string = )'[^']*'/,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Optional (nit): .replace() returns the source unchanged when this pattern finds nothing, and the file is then written as is, so a future change to the declaration's form would make pnpm run update-version a silent no-op (the previous pattern does exactly that against the annotated form). A guard keeps it loud:

const pattern = /(export const SUPPORTED_YJS_VERSION: string = )'[^']*'/;
const source = fs.readFileSync(modulePath, 'utf8');
if (!pattern.test(source)) {
  throw new Error(
    `${SUPPORTED_YJS_MODULE}: no SUPPORTED_YJS_VERSION declaration matches ${pattern}`,
  );
}
const next = source.replace(pattern, `$1'${supported}'`);

@zurfyx
zurfyx added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit fcea4ff Oct 30, 2026
57 of 58 checks passed

This branch was successfully deployed

2 active deployments
Preview – lexical — 874806a4 Deployed Oct 30, 2026 by vercel[bot]
Preview – lexical-playground — 874806a4 Deployed Oct 30, 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.

1 participant