-
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] Feature: error checking for node key re-use with type mismatch in __DEV__ #6014
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
c574eb6
to
6361bff
Compare
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.
looks good 👍
I have a small concern about the size here - would be nice to be able to tree-shake this stuff out of the prod build. |
Discussed offline - we'll follow up and ensure that we're doing what we can to shake out these DEV things in rollup |
Just for posterity's sake I did confirm that unused functions that do not get exported are tree-shaken correctly in both the |
Description
Based on issues that several people have run into, it seems useful to add some additional invariant checking around node keys.
See also: discord message
__DEV__
check to make sure that if a new Node is created with an explicit existing key, that the type of the node did not changeTest plan
Before
Bad things will silently happen if you accidentally re-use node keys, such as with a subtly incorrect node replacement function:
After
An error message is shows up now, in
__DEV__.
There are unit tests that verify that the specific error message comes up when creating a new node in this way (tested in isolation and with a node replacer).