Skip to content

[*] Bug Fix: Keep modern Flow variance keywords in the www Flow stubs - #9154

Merged
etrepum merged 1 commit into
meta:mainfrom
potatowagon:flow-variance-prettier-3-8-5
Sep 11, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
potatowagon:flow-variance-prettier-3-8-5

Conversation

@potatowagon

Copy link
Copy Markdown
Contributor

Description

scripts/www/transformFlowFileContents.mjs reprints every packages/*/flow/*.js.flow
stub through hermes-transform, which prints via prettier. Since #9143 bumped
hermes-transform to 0.37.0 while the prettier override in pnpm-workspace.yaml
held prettier at 3.8.1, that pairing prints the modern variance keywords as the
deprecated sigil, and inverts them: readonly and out both come out as -,
which Flow reads as contravariant.

The www copies are @flow strict and land in a Flow-checked tree, so every
affected property fails the unsupported-syntax lint:

Error -------------------------------- html/shared/lexical/Lexical.js.flow:1528:3
The `-` variance sigil is deprecated. Use `writeonly` instead. [unsupported-syntax]

  1528|   -type: 'node-caret-range';
          ^

80 properties across Lexical, LexicalHtml, LexicalUtils and
LexicalExtension are affected — every readonly/out/in annotation the
stubs declare.

prettier 3.8.5 prints the keywords correctly, so this raises the override (and
the matching devDependency floor) from 3.8.1 to 3.8.5, and adds a
transformFlowFileContents case asserting that variance syntax round-trips
unchanged.

Note that prettier-plugin-hermes-parser is no longer a peer dependency of
hermes-transform as of 0.37.0 and does not affect this either way — 0.36.1 and
0.37.0 of the plugin, and no plugin at all, all print the same.

Test plan

Reprinting the four real stubs through the repo's own transform, counting lines
that come out with a - sigil:

Before

$ node check.mjs
packages/lexical/flow/Lexical.js.flow: 62 bad lines
    -__isInlineFormattable: true;
    declare export class DOMSlot<-T extends HTMLElement> {
    -element: T;
packages/lexical-html/flow/LexicalHtml.js.flow: 12 bad lines
    -cfg: ContextConfig<Ctx, V>,
    -updater: (prev: V) => V,
    -nodes: '*' | ReadonlyArray<NodeMatch<T>>,
packages/lexical-utils/flow/LexicalUtils.js.flow: 4 bad lines
    -stateConfig: StateConfig<K, V>,
    -$get: <T extends LexicalNode>(node: T) => V,
    -$set: <T extends LexicalNode>(
packages/lexical-extension/flow/LexicalExtension.js.flow: 2 bad lines
    -value: T;
    -data: {[string]: unknown},
prettier resolved: 3.8.1
$ npx vitest run scripts/www/__tests__/unit/transformFlowFileContents.test.ts

 FAIL  |scripts-unit| scripts/www/__tests__/unit/transformFlowFileContents.test.ts > transformFlowFileContents > transforms variance keywords
AssertionError: expected '/**\n * Copyright (c) Meta Platforms,…' to be '/**\n * Copyright (c) Meta Platforms,…' // Object.is equality

- Expected
+ Received

   export interface InlineFormattableNode {
-    readonly __isInlineFormattable: true;
+    -__isInlineFormattable: true;
   }
-  declare export class DOMSlot<out T extends HTMLElement> {
+  declare export class DOMSlot<-T extends HTMLElement> {
-    readonly element: T;
+    -element: T;
-    readonly before: Node | null;
+    -before: Node | null;
   }
-  export type ContextRecord = {readonly [string | symbol]: unknown};
+  export type ContextRecord = {-[string | symbol]: unknown};
-  declare export function $setState<in T>(value: T): void;
+  declare export function $setState<-T>(value: T): void;

 Test Files  1 failed (1)
      Tests  1 failed | 4 passed (5)

After

$ node check.mjs
packages/lexical/flow/Lexical.js.flow: 0 bad lines
packages/lexical-html/flow/LexicalHtml.js.flow: 0 bad lines
packages/lexical-utils/flow/LexicalUtils.js.flow: 0 bad lines
packages/lexical-extension/flow/LexicalExtension.js.flow: 0 bad lines
prettier resolved: 3.8.5
$ npx vitest run scripts/www/__tests__/unit/transformFlowFileContents.test.ts

 ✓ |scripts-unit| scripts/www/__tests__/unit/transformFlowFileContents.test.ts (5 tests) 142ms

 Test Files  1 passed (1)
      Tests  5 passed (5)

npx prettier --list-different reports no change on the files this PR touches.

## Description

`scripts/www/transformFlowFileContents.mjs` reprints every `packages/*/flow/*.js.flow`
stub through `hermes-transform`, which prints via prettier. Since meta#9143 bumped
hermes-transform to 0.37.0 while the `prettier` override in `pnpm-workspace.yaml`
held prettier at 3.8.1, that pairing prints the modern variance keywords as the
deprecated sigil, and inverts them: `readonly` and `out` both come out as `-`,
which Flow reads as contravariant.

The www copies are `@flow strict` and land in a Flow-checked tree, so every
affected property fails the `unsupported-syntax` lint:

```
Error -------------------------------- html/shared/lexical/Lexical.js.flow:1528:3
The `-` variance sigil is deprecated. Use `writeonly` instead. [unsupported-syntax]

  1528|   -type: 'node-caret-range';
          ^
```

80 properties across `Lexical`, `LexicalHtml`, `LexicalUtils` and
`LexicalExtension` are affected — every `readonly`/`out`/`in` annotation the
stubs declare.

prettier 3.8.5 prints the keywords correctly, so this raises the override (and
the matching devDependency floor) from 3.8.1 to 3.8.5, and adds a
`transformFlowFileContents` case asserting that variance syntax round-trips
unchanged.

Note that `prettier-plugin-hermes-parser` is no longer a peer dependency of
hermes-transform as of 0.37.0 and does not affect this either way — 0.36.1 and
0.37.0 of the plugin, and no plugin at all, all print the same.

## Test plan

Reprinting the four real stubs through the repo's own transform, counting lines
that come out with a `-` sigil:

### Before

```
$ node check.mjs
packages/lexical/flow/Lexical.js.flow: 62 bad lines
    -__isInlineFormattable: true;
    declare export class DOMSlot<-T extends HTMLElement> {
    -element: T;
packages/lexical-html/flow/LexicalHtml.js.flow: 12 bad lines
    -cfg: ContextConfig<Ctx, V>,
    -updater: (prev: V) => V,
    -nodes: '*' | ReadonlyArray<NodeMatch<T>>,
packages/lexical-utils/flow/LexicalUtils.js.flow: 4 bad lines
    -stateConfig: StateConfig<K, V>,
    -$get: <T extends LexicalNode>(node: T) => V,
    -$set: <T extends LexicalNode>(
packages/lexical-extension/flow/LexicalExtension.js.flow: 2 bad lines
    -value: T;
    -data: {[string]: unknown},
prettier resolved: 3.8.1
```

```
$ npx vitest run scripts/www/__tests__/unit/transformFlowFileContents.test.ts

 FAIL  |scripts-unit| scripts/www/__tests__/unit/transformFlowFileContents.test.ts > transformFlowFileContents > transforms variance keywords
AssertionError: expected '/**\n * Copyright (c) Meta Platforms,…' to be '/**\n * Copyright (c) Meta Platforms,…' // Object.is equality

- Expected
+ Received

   export interface InlineFormattableNode {
-    readonly __isInlineFormattable: true;
+    -__isInlineFormattable: true;
   }
-  declare export class DOMSlot<out T extends HTMLElement> {
+  declare export class DOMSlot<-T extends HTMLElement> {
-    readonly element: T;
+    -element: T;
-    readonly before: Node | null;
+    -before: Node | null;
   }
-  export type ContextRecord = {readonly [string | symbol]: unknown};
+  export type ContextRecord = {-[string | symbol]: unknown};
-  declare export function $setState<in T>(value: T): void;
+  declare export function $setState<-T>(value: T): void;

 Test Files  1 failed (1)
      Tests  1 failed | 4 passed (5)
```

### After

```
$ node check.mjs
packages/lexical/flow/Lexical.js.flow: 0 bad lines
packages/lexical-html/flow/LexicalHtml.js.flow: 0 bad lines
packages/lexical-utils/flow/LexicalUtils.js.flow: 0 bad lines
packages/lexical-extension/flow/LexicalExtension.js.flow: 0 bad lines
prettier resolved: 3.8.5
```

```
$ npx vitest run scripts/www/__tests__/unit/transformFlowFileContents.test.ts

 ✓ |scripts-unit| scripts/www/__tests__/unit/transformFlowFileContents.test.ts (5 tests) 142ms

 Test Files  1 passed (1)
      Tests  5 passed (5)
```

`npx prettier --list-different` reports no change on the files this PR touches.
@vercel

vercel Bot commented Sep 11, 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 11, 2026 9:07am UTC
lexical-playground Ready Ready Preview Sep 11, 2026 9:07am 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 11, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 11, 2026
Merged via the queue into meta:main with commit 74030d1 Sep 11, 2026
46 checks passed
etrepum pushed a commit to etrepum/lexical that referenced this pull request Sep 11, 2026
Conflicts came from meta#9154, which bumped prettier to 3.8.5 (both the root
devDependency and the pnpm-workspace.yaml override) so the www Flow stubs keep
modern variance keywords, while this branch bumps its neighbouring
prettier-plugin-* entries.

- package.json: prettier ^3.8.5 from main, prettier-plugin-hermes-parser
  ^0.37.0 from the dependency group bump.
- pnpm-lock.yaml: regenerated with `pnpm install --lockfile-only` instead of
  resolving the generated file by hand. The only delta against this branch is
  prettier 3.8.1 -> 3.8.5, with the same integrity hash main resolved.

Verified with `pnpm run ci-check` (exit 0) and `pnpm run test-unit`
(324 files, 7317 passed | 1 skipped), which covers the
transformFlowFileContents cases meta#9154 added against prettier 3.8.5 and
prettier-plugin-hermes-parser 0.37.0.

Co-Authored-By: Claude Opus 5 <[email protected]>
etrepum pushed a commit to etrepum/lexical that referenced this pull request Sep 11, 2026
## Description

The dev-dependencies group bump raised `@types/node` to `^26.4.1` in the root
package.json, but `pnpm-workspace.yaml` pins the whole workspace to
`'@types/node': '25.9.1'` through `overrides`, so the bump never took effect:
the lockfile still recorded `specifier: 25.9.1` for the root importer and every
package kept resolving 25.x while the manifest advertised 26.x.

The override has to move with the dependency — the same way meta#9154 bumped
prettier in both places — so this sets it to `26.4.1`. `@types/node` 26 pulls
`undici-types` 8.3.0 in place of 7.24.6; nothing else in the lockfile changes.

## Test plan

### Before

```
$ grep -n "@types/node" package.json pnpm-workspace.yaml
package.json:144:    "@types/node": "^26.4.1",
pnpm-workspace.yaml:22:  '@types/node': '25.9.1'

$ grep -A2 "'@types/node':" pnpm-lock.yaml   # root importer
      '@types/node':
        specifier: 25.9.1
        version: 25.9.1
```

### After

```
$ grep -A2 "'@types/node':" pnpm-lock.yaml   # root importer
      '@types/node':
        specifier: 26.4.1
        version: 26.4.1

$ pnpm install
- @types/node 25.9.1
+ @types/node 26.4.1

$ pnpm run ci-check
$ npm-run-all --parallel tsc tsc-scripts tsc-extension tsc-website flow prettier lint
No errors!
(exit 0)

$ pnpm run build-types
$ tsc -p ./tsconfig.build.json && node ./scripts/validate-tsc-types.mjs
(exit 0)
```

Co-Authored-By: Claude Opus 5 <[email protected]>
@etrepum etrepum mentioned this pull request Sep 17, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — e2b04b18 Deployed Sep 11, 2026 by vercel[bot]
Preview – lexical-playground — e2b04b18 Deployed Sep 11, 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.

3 participants