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

Enhance type of TabAction component #1126

Closed
3 tasks
yangwooseong opened this issue Feb 8, 2023 · 0 comments · Fixed by #1497
Closed
3 tasks

Enhance type of TabAction component #1126

yangwooseong opened this issue Feb 8, 2023 · 0 comments · Fixed by #1497
Assignees
Labels
bug Issues related to anything that isn't working

Comments

@yangwooseong
Copy link
Collaborator

yangwooseong commented Feb 8, 2023

Summary

TabAction component 의 type 추론이 정확히 되지 않습니다.

Reproduction process

TabAction 컴포넌트는 button element 으로 사용할 수도 있고, anchor element 로도 사용할 수 있습니다. 원래 의도는 href prop 을 지정하게 되면 알아서 anchor element 로 타입 추론이 되게 하는 것이었는데, type assertion 을 지우면서 의도와는 달리 항상 button element 로 추론되고 있습니다. ref forwarding 을 하면서 타입 추론이 잘못 되고 있는 것으로 보입니다. assertion 을 하지 않고도 올바르게 타입 추론이 되도록 타입 선언이 수정되어야 합니다.

현재 상황 - 무조건 HTMLButtonElement 의 속성을 갖도록 추론됨

image

바람직한 상황 - href prop 을 지정하면 HTMLAnchorElement 로, 그렇지 않으면 HTMLButtonElement 속성을 갖도록 추론됨

image

image

추가) https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref 에 따르면 forwardRef로 넘길 때 제네릭이 완벽하게 동작하지 않는 것은 typescript 의도 인것 같음

Version of bezier-react

@1.0.0-next-v1.180

Browser

No response

Operating system

  • macOS
  • Windows
  • Linux

Additonal Information

No response

@yangwooseong yangwooseong added the bug Issues related to anything that isn't working label Feb 8, 2023
@yangwooseong yangwooseong self-assigned this Mar 16, 2023
@github-project-automation github-project-automation bot moved this to 📌 Backlog in Bezier React Apr 3, 2023
@github-project-automation github-project-automation bot moved this from 📌 Backlog to ✅ Done in Bezier React Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to anything that isn't working
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant