Open thesunny opened 4 years ago
According to this, element.children should also return Element[] or Text[], right? If that is the case, wouldn't this require an entire transformation of the Node[] interface? Since it would no longer be the child of anything? @timbuckley @BrentFarese
I agree that Editor.children
should be of type Element[]
, to preserve the logic described in the docs @thesunny mentioned above.
Also, Element.children
should be of type Descendant[]
.
This might be a quick and easy PR, worth trying. There may be a bunch of type guards in the codebase that will need to be changed to accommodate this - some may be obviated entirely.
Update on this: I created the following branch https://github.com/arity-contracts/slate/tree/node-change. I attempted to change the Editor.children to Element, but this led to type issues because some of the Editor functions were supposed to return Element | Text | Boolean. To solve this, I created a type that was either Text | Element | Boolean. I also tested out NodeEntry
Do you want to request a feature or report a bug?
bug
What's the current behavior?
Calling
editor.children
returns typeNode[]
Slate: 0.58.3
What's the expected behavior?
Based on this documentation https://docs.slatejs.org/concepts/10-normalizing
We are told the following:
Therefore,
editor.children
should return typeElement[]
since it cannot beEditor[]
orText[]