-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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] Fix flow error: change this to any #6992
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should explore the generics route we're using for other functions, or just use FlowFixMe in product code like we're using already for other methods
In this case the downstream code's type annotation is wrong, up to you whether you put FlowFixMe here to work around the wrong annotation in downstream code or not. It doesn't affect any OSS users because almost nobody uses flow outside of Meta.
Should be:
|
Specifically updateDOM is always called with another instance of the exact same class ( |
thanks for looking into this, changing to
same as sample error linked in the description |
That might be a problem with Flow then, it might not be able to represent this constraint. Possibly always specifying the exact class that is overriding the method will work? Or maybe there is another Flow specific trick that can be used here? Last time I used Flow it was very different. |
Seems that flow isnt able to compile
this
type as an input param type: see sampleerror
This results in downstream errors such as this scenerio:
In this example, super is a TextNode, and prevNode, being this typed, should be a TextNode, but flow isnt able to determine that. The error:
In this PR, changing this to any as a quick fix for the flow apis. Will look into adding stricter typing for each node's updateDom in future PRs, refer to https://github.com/facebook/lexical/pull/6894/files for possible places
I also tried changing the flow api to
updateDOM(prevNode: LexicalNode, ...
but that resulted in errors everywhere as flow isnt able to eg. tell that a ParagraphNode is a LexicalNode, strangely.