Skip to content

[lexical] Bug Fix: Missing variables and functions in Flow file - #6866

Closed
lytion wants to merge 3 commits into
meta:mainfrom
lytion:patch-1
Closed

lytion wants to merge 3 commits into
meta:mainfrom
lytion:patch-1

Conversation

@lytion

@lytion lytion commented Nov 25, 2024

Copy link
Copy Markdown
Contributor

Missing variables and functions in Flow file.

Description

I found that some variables and function are missing in the lexical Flow file, here is a suggested fix.

Missing variables and functions in Flow file.
@facebook-github-bot

Copy link
Copy Markdown
Contributor

Hi @lytion!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@vercel

vercel Bot commented Nov 25, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 3:46pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 3:46pm

@github-actions

github-actions Bot commented Nov 25, 2024 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
lexical - cjs 31.29 KB (0%)
lexical - esm 31.11 KB (0%)
@lexical/rich-text - cjs 40.34 KB (0%)
@lexical/rich-text - esm 33.04 KB (0%)
@lexical/plain-text - cjs 38.88 KB (0%)
@lexical/plain-text - esm 30.3 KB (0%)
@lexical/react - cjs 42.12 KB (0%)
@lexical/react - esm 34.29 KB (0%)

@facebook-github-bot facebook-github-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 Nov 25, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@@ -256,6 +256,7 @@ export type EditorThemeClasses = {
ulDepth?: Array<EditorThemeClassName>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

when i run flow on these changes i get this error, other files may need updating

[[email protected] /data/sandcastle/boxes/www (c0d10ff15)]$ flow
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ html/shared/lexical/Lexical.js.flow:469:22

Cannot implement BaseSelection [1] with NodeSelection because property _cachedNodes is missing in NodeSelection [2]
but exists in BaseSelection [1]. [prop-missing]

        466│   setCachedNodes(nodes: null | Array<LexicalNode>): void;
        467│ }
        468│
 [2][1] 469│ declare export class NodeSelection implements BaseSelection {
        470│   _nodes: Set<NodeKey>;
        471│   dirty: boolean;
        472│   constructor(objects: Set<NodeKey>): void;


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ html/shared/lexical/Lexical.js.flow:469:22

Cannot implement BaseSelection [1] with NodeSelection because property getStartEndPoints is missing in
NodeSelection [2] but exists in BaseSelection [1]. [prop-missing]

        466│   setCachedNodes(nodes: null | Array<LexicalNode>): void;
        467│ }
        468│
 [2][1] 469│ declare export class NodeSelection implements BaseSelection {
        470│   _nodes: Set<NodeKey>;
        471│   dirty: boolean;
        472│   constructor(objects: Set<NodeKey>): void;


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ html/shared/lexical/Lexical.js.flow:469:22

Cannot implement BaseSelection [1] with NodeSelection because property isBackward is missing in NodeSelection [2]
but exists in BaseSelection [1]. [prop-missing]

        466│   setCachedNodes(nodes: null | Array<LexicalNode>): void;
        467│ }
        468│
 [2][1] 469│ declare export class NodeSelection implements BaseSelection {
        470│   _nodes: Set<NodeKey>;
        471│   dirty: boolean;
        472│   constructor(objects: Set<NodeKey>): void;


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ html/shared/lexical/Lexical.js.flow:469:22

Cannot implement BaseSelection [1] with NodeSelection because property isCollapsed is missing in NodeSelection [2]
but exists in BaseSelection [1]. [prop-missing]

        466│   setCachedNodes(nodes: null | Array<LexicalNode>): void;
        467│ }
        468│
 [2][1] 469│ declare export class NodeSelection implements BaseSelection {
        470│   _nodes: Set<NodeKey>;
        471│   dirty: boolean;
        472│   constructor(objects: Set<NodeKey>): void;


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ html/shared/lexical/Lexical.js.flow:493:22

Cannot implement BaseSelection [1] with RangeSelection because property _cachedNodes is missing in
RangeSelection [2] but exists in BaseSelection [1]. [prop-missing]

        490│   x: ?mixed,
        491│ ): x is NodeSelection;
        492│
 [2][1] 493│ declare export class RangeSelection implements BaseSelection {
        494│   anchor: PointType;
        495│   focus: PointType;
        496│   dirty: boolean;


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ html/shared/lexical/Lexical.js.flow:493:22

Cannot implement BaseSelection [1] with RangeSelection because property getStartEndPoints is missing in
RangeSelection [2] but exists in BaseSelection [1]. [prop-missing]

        490│   x: ?mixed,
        491│ ): x is NodeSelection;
        492│
 [2][1] 493│ declare export class RangeSelection implements BaseSelection {
        494│   anchor: PointType;
        495│   focus: PointType;
        496│   dirty: boolean;


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ html/shared/lexical/LexicalTable.js.flow:323:22

Cannot implement BaseSelection [1] with TableSelection because property _cachedNodes is missing in
TableSelection [2] but exists in BaseSelection [1]. [prop-missing]

        320│   toX: number,
        321│   toY: number,
        322│ };
 [2][1] 323│ declare export class TableSelection implements BaseSelection {
        324│   tableKey: NodeKey;
        325│   anchor: PointType;
        326│   focus: PointType;



Found 7 errors

The Flow server is currently in lazy mode and is only checking 585463/1396902 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is weird, I can see these functions in https://lexical.dev/docs/api/interfaces/lexical.BaseSelection
I directly added this on my project and everything was fine but maybe I'm missing out something. I will try on the repo when I have some time

Comment thread packages/lexical/flow/Lexical.js.flow Outdated

export interface BaseSelection {
clone(): BaseSelection;
_cachedNodes: Array<LexicalNode> | null;

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.

I don't think this should be here. It's not a public interface

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agree, and its breaking other apis too

Comment thread packages/lexical/flow/Lexical.js.flow Outdated
}
export type TextPoint = TextPointType;
type TextPointType = {
_selection: BaseSelection,

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.

_selection isn't part of the public interface for these point types either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My bad, I must have used it incorrectly. I was trying to access rangeSelection.anchor._selection.getStartEndPoints() but I guess I should have used rangeSelection.getStartEndPoints().

@lytion

lytion commented Nov 26, 2024

Copy link
Copy Markdown
Contributor Author

I removed all private variables and added missing functions in RangeSelection that I found on https://lexical.dev/docs/api/classes/lexical.RangeSelection

@potatowagon

Copy link
Copy Markdown
Contributor

https://github.com/facebook/lexical/actions/runs/12027063755/job/33527314547?pr=6866

npm run ci-check which runs flow has errors,

Cannot implement BaseSelection [1] with NodeSelection because property getStartEndPoints is missing in
NodeSelection [2] but exists in BaseSelection [1]. [prop-missing]

@lytion

lytion commented Dec 18, 2024

Copy link
Copy Markdown
Contributor Author

Will create a new PR without using the github editor system which I'm not used to of

This branch was successfully deployed

2 active deployments
Preview – lexical — 28589406 Deployed Dec 18, 2024 by vercel[bot]
Preview – lexical-playground — 28589406 Deployed Dec 18, 2024 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.

4 participants