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

Polymorphic component overrides doesn't seem to work with TypeScript #282

Closed
3 of 15 tasks
brionmario opened this issue Oct 10, 2024 · 0 comments · Fixed by #281
Closed
3 of 15 tasks

Polymorphic component overrides doesn't seem to work with TypeScript #282

brionmario opened this issue Oct 10, 2024 · 0 comments · Fixed by #281
Assignees
Labels
bug Something isn't working hacktoberfest Issues dedicated for the annual annual Hacktoberfest open source festival. package:react Issues/PRs related to the `@oxygen-ui/react` package.

Comments

@brionmario
Copy link
Member

brionmario commented Oct 10, 2024

Describe the issue:

Typings doesn't properly work when component prop is used and trying to add a specific prop related to the overriden component.

Ex:

Screenshot 2024-10-10 at 14 37 12

Stack Trace

Type '{ children: Element[]; component: "h1" | C; style?: CSSProperties; classes?: Partial<CardClasses> & Partial<ClassNameMap<never>>; ... 261 more ...; className: string; }' is not assignable to type 'IntrinsicAttributes & { component?: ElementType; } & Omit<CardProps<"div", {}>, "component">'. Property 'href' does not exist on type 'IntrinsicAttributes & { component?: ElementType; } & Omit<CardProps<"div", {}>, "component">'. Did you mean 'ref'?ts(2322)

How to reproduce:

  • Get the Card component
  • Override using the a elemet
  • add anchor element specific prop like href

Expected behavior:

Typescript should not complain and should provide necessary intellisense.

Additional context :

  • Affected Package:
    • @oxygen-ui/logger
    • @oxygen-ui/primitives
    • @oxygen-ui/react
    • @oxygen-ui/react-icons
  • Library Version: [e.g., 1.10.0, 2.0.0-alpha]
  • OS:
    • Windows
    • Linux
    • Mac
    • Other
  • Browser:
    • Google Chrome
    • Firefox
    • Safari
    • Microsoft Edge
    • Brave
    • Opera
    • Other

Optional Fields

Related issues:

@brionmario brionmario added bug Something isn't working package:react Issues/PRs related to the `@oxygen-ui/react` package. labels Oct 10, 2024
@brionmario brionmario self-assigned this Oct 10, 2024
@brionmario brionmario added the hacktoberfest Issues dedicated for the annual annual Hacktoberfest open source festival. label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest Issues dedicated for the annual annual Hacktoberfest open source festival. package:react Issues/PRs related to the `@oxygen-ui/react` package.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant