Skip to content

[EuiCallOut] TypeScript requiring unnecessary prop translate #4660

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

Closed
i-a-n opened this issue Mar 22, 2021 · 4 comments
Closed

[EuiCallOut] TypeScript requiring unnecessary prop translate #4660

i-a-n opened this issue Mar 22, 2021 · 4 comments
Labels
⚠️ needs validation For bugs that need confirmation as to whether they're reproducible

Comments

@i-a-n
Copy link
Contributor

i-a-n commented Mar 22, 2021

It seems the use of Pick<> in the <EuiCallOut> type def is leading to unintentionally required props, specifically, it requires me to use "translate" in order to satisfy its requirements. Example—this code:

        <EuiCallOut
          title={
            <EuiI18n
              token="contacts.maxContactsTitle"
              default="Maximum number of contacts reached"
            />
          }
          color="danger"
          iconType="alert"
        >

...leads to this error:

Property 'translate' is missing in type '{ children: (string | Element)[]; title: Element; color: "danger"; 
iconType: string; }' but required in type 'Pick<HTMLAttributes<HTMLDivElement>, "children" | "dir" |
"slot" | "style" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | ... 244 more ... | 
"translate">'.ts(2741)

And this "fixes" it:

        <EuiCallOut
          title={
            <EuiI18n
              token="contacts.maxContactsTitle"
              default="Maximum number of contacts reached"
            />
          }
          color="danger"
          iconType="alert"
          translate
        >

Asking about this in #eui led to Chandler noting:

the TS-provided Pick isn't distributive microsoft/TypeScript#28339
We have (and export) a DistributivePick to solve it, looks like we may need to apply it somewhere on EuiCallOut. Would you mind opening an issue?

So here we are. Thanks for taking a look.

@chandlerprall
Copy link
Contributor

What are the versions of typescript and eui you are using? Tried replicating this within eui with the latest master but it works as expected.

@chandlerprall chandlerprall added the ⚠️ needs validation For bugs that need confirmation as to whether they're reproducible label Mar 22, 2021
@i-a-n
Copy link
Contributor Author

i-a-n commented Mar 22, 2021

@chandlerprall

I'm using EUI 31.9.1 and TypeScript 3.9.9

@i-a-n
Copy link
Contributor Author

i-a-n commented Mar 24, 2021

note: I've upgraded to TypeScript 4.0.5 and the problem remains

@i-a-n
Copy link
Contributor Author

i-a-n commented Mar 25, 2021

note!: this was due to my version of @types/react being outdated. upgrading from @types/[email protected] to @types/[email protected] fixed it. how about that.

@i-a-n i-a-n closed this as completed Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ needs validation For bugs that need confirmation as to whether they're reproducible
Projects
None yet
Development

No branches or pull requests

2 participants