-
Notifications
You must be signed in to change notification settings - Fork 1
feat: refactor arrow to typescript #175 #184
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Charlie, how are things? :-)
Thanks for making a start working on this. I think it'd be nice if we could phase out PropTypes as we introduce TypeScript. And should the getArrowPosition
function be converted to TS, too? (I haven't looked at it just now, just wondering if that would make things more consistent or robust)
src/Arrow/index.tsx
Outdated
@@ -37,7 +38,7 @@ function useArrowStyles(primaryPlacement, arrowSize) { | |||
return arrowStyles; | |||
} | |||
|
|||
const Arrow = forwardRef((props, ref) => { | |||
const Arrow = forwardRef((props: {placement: string, size: number, distanceFromEdge: number, style}, ref: React.RefObject<HTMLElement>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The placement
prop can be defined more granularly based on the PLACEMENTS
constant – or maybe you can even import that type from popperJS. Should result in a nice auto-complete for this prop, as only a limited number of strings are actually allowed as values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Charlie. Just some comments.
|
||
import {POPPER_PLACEMENTS} from '../constants'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like you could still create a type from this constant as described here: https://stackoverflow.com/a/62900613
(At least if it's safe to convert the constants file to TypeScript, too.)
Co-authored-by: diondiondion <[email protected]>
…into ts-refactor-arrow
🎉 This PR is included in version 14.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Arrow component, with added types