Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Narrows type of
parent
in render functions. (#3863)
* Narrows type of `parent` in render functions. https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c is the recommended way to partial root rendering in Preact 10+, but it isn't API compliant code given the current API definition as expressed by the TS types. This PR changes the type of `parent` to align with what is *actually* required by the preact render functions according to @developit. Assuming the linked code actually works, then it means preact doesn't actually need a NodeList, but rather just needs an `ArrayLike<Node>`. Along with limiting the property set of `Parent`, I have also narrowed `Parent['childNodes']` to be an `ArrayLike<Node>` so someone can assign a `Node[]` to it. I suspect my stylistic choice of a single long line is not acceptable for this repository, but I'm not clear what the proper way to break this into multiple lines is for this repository. If someone can provide me with feedback on how to correctly split the lines, please let me know! Note: I recognize that this is a pretty substantial type change, but without it the official recommendation (and only option in Preact 11) for doing partial root rendering is incorrect. Either the recommendation for how to do partial root rendering should be corrected to not lead people to an incorrect solution, or this PR (or one like it) should be merged to correctly express the type that preact expects for its `render` functions. * Update index.d.ts * Update src/index.d.ts Co-authored-by: Andre Wiggins <[email protected]> * Update preact.tsx --------- Co-authored-by: Andre Wiggins <[email protected]>
- Loading branch information