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
Fix @reach/router Link
base type
#3546
base: master
Are you sure you want to change the base?
Conversation
@@ -71,7 +71,7 @@ declare module '@reach/router' { | |||
|}>; | |||
|
|||
declare export type LinkProps<State> = { | |||
...$Shape<HTMLAnchorElement>, | |||
...React$ElementProps<string>, |
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.
Why not ...React$ElementProps<'a'>
?
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.
@reach/router
spreads Link
props over <a/>
element: https://github.com/reach/router/blob/master/src/index.js#L385-L398
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.
My thought was to make it more generic. I could imagine that Link
component would render another element like span
.
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.
@reach/router
is very accessibility-centric, so I don't think they will ever allow using spans as links
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.
They actually even advertise using native links as a feature =)
https://reach.tech/router/accessibility
This comment has been minimized.
This comment has been minimized.
Doesn't feel like the right fix.
|
@pascalduez what would be the right one? |
Oh I see. Looks like Flow doesn't validate DOM props at all: It should probably be fixed with facebook/flow#7569 |
I guess |
What's missing to be able to move here, I guess adding tests to assert the proper intended behaviour? |
Other notes: This change fixes the problem when
flow@1.106.x
expects all props ofHTMLAnchorElement
to be present in aLink
instance.