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

[core] fix(IconProps): widen type of HTML attributes #6283

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

adidahiya
Copy link
Contributor

Changes proposed in this pull request:

Fix a regression introduced by #6235 where consumers' usage of HTML attribute props on <Icon> stopped compiling successfully due to the more specific React.HTMLAttributes<T> type. This caused compilation errors such as:

  Types of parameters 'evt' and 'event' are incompatible.
    Type 'MouseEvent<HTMLElement | SVGSVGElement, MouseEvent>' is not assignable to type 'SyntheticEvent<HTMLSpanElement, Event>'.
      Types of property 'currentTarget' are incompatible.
        Type 'EventTarget & (HTMLElement | SVGSVGElement)' is not assignable to type 'EventTarget & HTMLSpanElement'.
          Type 'EventTarget & SVGSVGElement' is not assignable to type 'EventTarget & HTMLSpanElement'.
            Type 'EventTarget & SVGSVGElement' is missing the following properties from type 'HTMLSpanElement': accessKey, accessKeyLabel, autocapitalize, dir, and 20 more.

250                     <Icon icon={IconNames.MORE} onClick={this.handleIconClick} />

The fix in this case is to widen the type of the element param in React.HTMLAttributes<T> which was inadvertently narrowed in #6235. Turns out that HTMLElement is really just an alias for Element (it adds no extra properties), so we were working with a pretty basic type in the first place.

Reviewers should focus on:

Fixes the regression. I verified this in consumer code by editing Blueprint's .d.ts files in node_modules.

@adidahiya adidahiya merged commit cc82165 into develop Jul 17, 2023
12 checks passed
@adidahiya adidahiya deleted the ad/fix-icon-type-regression branch July 17, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant