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

Switch from using React.HTMLProps to React.HTMLAttributes #1967

Merged

Conversation

MLoughry
Copy link
Contributor

@MLoughry MLoughry commented Jun 9, 2017

Props that extend React.HTMLProps are difficult to extend, because you end up getting errors like the following if you try to extend them:

[12:20:04] packages/options/owa-options-mail/lib/components/common/ChoiceGroupWithImages.tsx(23,17): error TS2322: Type '{ options: any[]; children?: ReactNode; componentRef?: (component: IChoiceGroup) => void;
  Type '{ options: any[]; children?: ReactNode; componentRef?: (component: IChoiceGroup) => void; default...' is not assignable to type 'IntrinsicClassAttributes<ChoiceGroup>'.
    Types of property 'ref' are incompatible.
      Type 'Ref<HTMLElement | HTMLInputElement>' is not assignable to type 'Ref<ChoiceGroup>'.
        Type '(instance: HTMLElement | HTMLInputElement) => any' is not assignable to type 'Ref<ChoiceGroup>'.
          Type '(instance: HTMLElement | HTMLInputElement) => any' is not assignable to type '(instance: ChoiceGroup) => any'.
            Types of parameters 'instance' and 'instance' are incompatible.
              Type 'ChoiceGroup' is not assignable to type 'HTMLElement | HTMLInputElement'.
                Type 'ChoiceGroup' is not assignable to type 'HTMLInputElement'.
                  Property 'accept' is missing in type 'ChoiceGroup'.

However, the ref and key props that make the only difference between HTMLProps and HTMLAttributes aren't really needed for the property interfaces. So, just get rid of them.

Copy link
Contributor

@mikewheaton mikewheaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@MLoughry MLoughry merged commit 9273411 into microsoft:master Jun 9, 2017
@MLoughry MLoughry deleted the types/switch-from-props-to-attributes branch July 13, 2017 03:04
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants