Support specific i18n value types in single-token usage#1861
Conversation
There was a problem hiding this comment.
I looked through the examples and understand the usage from a consumer's view. I merged this into #1848 where I was having issues and it now compiles. I am running into an issue I think with VSCode where it still likes to complain and I think this is due to some silly linting bits, but the TS now compiles and I'm assuming my issues are tied to VSCode being noisy. But everything works fine in the actual usage, so this is LGTM.
Here's the goofyness I saw if anyone with VScode wants to check.
|
@snide The errors you see look to be related to VSCode. I pulled your branch and merged this branch, and did initially see the 2nd ( |
|
Yep. I'm OK with this merging. Can update my PR directly after and merge as well. |
thompsongl
left a comment
There was a problem hiding this comment.
Code looks good. As noted, I was able build locally.
No CL entry needed?


Summary
Updates types for
EuiI18nfor convenience when passing localized values to string-type props, e.g.aria-label. This does not change any functionality, only makes it easier to consume in a common case.Given the setup,
TS would error passing the ReactChild to aria-label as it cannot downcast ReactChild to a string. It is not possible to type the incoming
labelasstringas the render prop function itself is typed asReactChild. This PR extends the types' logic for single-token use cases (as above) to retain thedefaultprop's type when calling the render prop function, and the above now works when rewritten to typelabelasstring.The new logic can also infer the type when the default value is a callback,
Although unchanged, there are underlying assumptions that any localized, mapped value retains the same type as
default. These changes make those assumptions more apparent (see the added type casting and related comments).This also fails to correctly type if the provided value uses our string interpolation to inject ReactElements. Compare,
Checklist
- [ ] This was checked in mobile- [ ] This was checked in IE11- [ ] This was checked in dark mode- [ ] Any props added have proper autodocs- [ ] Documentation examples were added- [ ] A changelog entry exists and is marked appropriately- [ ] This was checked against keyboard-only and screenreader scenarios- [ ] This required updates to Framer X components