Skip to content
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

TypeScript: Incompatible 'aria-invalid' types for Select #4940

Closed
prichey opened this issue Dec 6, 2021 · 4 comments · Fixed by #4941
Closed

TypeScript: Incompatible 'aria-invalid' types for Select #4940

prichey opened this issue Dec 6, 2021 · 4 comments · Fixed by #4941
Labels
issue/bug-confirmed Issues about a bug that has been confirmed by a maintainer issue/has-pr Issue has a PR attached to it that may solve the issue

Comments

@prichey
Copy link
Contributor

prichey commented Dec 6, 2021

I'm having some issues satisfying TypeScript when upgrading from react-select v4 (4.3.1) to v5 (5.2.1).

The crux of it is this:

Type '{ styles: StylesConfig<SelectInputOption<T>, false, GroupBase<SelectInputOption<T>>>; options: SelectInputOption<T>[]; ... 356 more ...; className: string; }' is not assignable to type 'Omit<Pick<Props<SelectInputOption<T>, false, GroupBase<SelectInputOption<T>>>, "aria-errormessage" | "aria-invalid" | ... 28 more ... | "form"> & Partial<...> & Partial<...>, StateManagedPropKeys>'.
  Types of property ''aria-invalid'' are incompatible.
    Type 'boolean | "false" | "true" | "grammar" | "spelling" | undefined' is not assignable to type 'boolean | undefined'.
      Type '"false"' is not assignable to type 'boolean | undefined'.

I can provide a relatively complete reproduction of my types if useful but TL;DR: up the tree I'm using AllHTMLAttributes<HTMLSelectElement> which pulls from React's own AriaAttributes type (deep link to 'aria-invalid' here). This type differs from what's declared as Props in Select.tsx, so when I spread props of one type onto the Select component, tsc yells at me.

IMO the types in Select should be modified to match those defined in AriaAttributes, since presumably the attribute should follow the same spec. Let me know if I'm missing something on my end, though!

@prichey prichey added the issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet label Dec 6, 2021
@prichey prichey changed the title TypeScript: Incompatible AriaAttributes types TypeScript: Incompatible 'aria-invalid' types for Select Dec 6, 2021
@prichey
Copy link
Contributor Author

prichey commented Dec 6, 2021

I have a naive PR up for this: #4941. This fix is preventing me from upgrading to v5 so please let me know if there's anything else I can do here!

@prichey
Copy link
Contributor Author

prichey commented Dec 8, 2021

@Rall3n tagging you since I see you've been doing triage on recent issues, please let me know what you think whenever you have a chance!

@Methuselah96
Copy link
Collaborator

As far as preventing you from upgrading to v5, can you just cast until it gets fixed here?

@Methuselah96 Methuselah96 added issue/bug-confirmed Issues about a bug that has been confirmed by a maintainer issue/has-pr Issue has a PR attached to it that may solve the issue and removed issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet labels Dec 8, 2021
@prichey
Copy link
Contributor Author

prichey commented Dec 8, 2021

I think I'd rather hold off on upgrading instead of introducing a brittle type cast. I'm happy to hold off until this gets sorted out (unless it gets put on ice for some reason)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/bug-confirmed Issues about a bug that has been confirmed by a maintainer issue/has-pr Issue has a PR attached to it that may solve the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants