-
Notifications
You must be signed in to change notification settings - Fork 178
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
[WIP] Attempted conversion of i18n package #12201
Conversation
const children = node.hasChildNodes() | ||
? [...childNodes].map((child) => transform(child, mapping)) | ||
: null; |
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 am pretty sure this old code is wrong, no? It loops over all the child nodes and transforms each, but transformNode
transform both the given node and all its following siblings, so this old code duplicates a lot of nodes, no?
Well, at least the type system told me that the children
variable had type ReactNode[][]
, which definitely seemed wrong.
if ('localName' in node) { | ||
const { localName } = node as Element; | ||
if (localName in mapping) { | ||
return cloneElement(mapping[localName], undefined, children); |
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.
For the life of me, I can't figure out how to get TS to accept the type of this one? I tried everything, but I can't match the types to any of the overloads available. And similarly for createElement
and its overloads a few lines below.
Merged #12198 now. Feel free to rebase your PR if you have any suggestions for improvements! |
Context
This is a first attempt at converting the i18n package to TypeScript.
Testing Instructions
Checklist
Type: XYZ
label to the PRFixes #