Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 3 commits into from

Conversation

lytion
Copy link
Contributor

@lytion lytion commented Nov 25, 2024

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
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!

Copy link

vercel bot commented Nov 25, 2024

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

Copy link

github-actions bot commented Nov 25, 2024

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
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
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
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

@@ -446,13 +447,17 @@ declare export function $isBlockElementNode(
): node is ElementNode;

export interface BaseSelection {
clone(): BaseSelection;
_cachedNodes: Array<LexicalNode> | null;
Copy link
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
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

@@ -528,6 +533,7 @@ declare export class RangeSelection implements BaseSelection {
}
export type TextPoint = TextPointType;
type TextPointType = {
_selection: BaseSelection,
Copy link
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
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
Copy link
Contributor Author

lytion commented Nov 26, 2024

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
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
Copy link
Contributor Author

lytion commented Dec 18, 2024

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

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