Repository navigation
[lexical-y] Chore: Type SUPPORTED_YJS_VERSION as a string, and keep the playground's @y/y pin in step - #9615
Conversation
…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) ```
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/y
@lexical/yjs
commit: |
There was a problem hiding this comment.
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:
- Changesets warning. The Changesets job flags
packages/lexical-y/src/internal/SupportedYjs.tsas published code without a changeset.SUPPORTED_YJS_VERSIONfirst ships with #9607's pending changeset, which already announces it, so a maintainer adding theskip-changesetlabel fits better than a new entry (CONTRIBUTING.md, "Changesets"). scripts/updateVersion.mjs, lines 136-146 (nit).regenerateSupportedYjsVersionwrites the module whether or not its pattern matched, so a future change to the declaration's form would turnpnpm run update-versioninto a silent no-op (the previous pattern does exactly that against the new annotated form), and the hint inYjsContract.test.tswould 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.
| .readFileSync(modulePath, 'utf8') | ||
| .replace( | ||
| /(export const SUPPORTED_YJS_VERSION = )'[^']*'/, | ||
| /(export const SUPPORTED_YJS_VERSION: string = )'[^']*'/, |
There was a problem hiding this comment.
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}'`);
Description
Follow-ups to #9607 from the review bot:
SUPPORTED_YJS_VERSIONwas published as a literal type(
export declare const SUPPORTED_YJS_VERSION = "14.0.0-rc.29"), so itsTypeScript type changed with every
@y/ybump, while the Flowdeclaration says
string. It is now declaredstring, asLEXICAL_VERSIONis;scripts/updateVersion.mjsmatches the new formwhen it regenerates the literal.
@y/yon its own (packages/lexical-playground),and nothing in the workspace ties it to
@lexical/y's pin, so a bumpthat 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, andYjsContract.test.tsnow fails when the playground's pin differs fromSUPPORTED_YJS_VERSION.Changeset
None:
SUPPORTED_YJS_VERSIONkeeps its value and is part of the unreleasedfeature #9607's changeset already describes; the rest is docs, a test and
tooling.
Test plan
Before
The emitted declaration:
The new assertion with the playground's pin set to
14.0.0-rc.28:After