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

[Link] Fix type declaration for props #14193

Merged
merged 1 commit into from
Jan 16, 2019
Merged

[Link] Fix type declaration for props #14193

merged 1 commit into from
Jan 16, 2019

Conversation

swsnr
Copy link
Contributor

@swsnr swsnr commented Jan 15, 2019

Derive from AnchorHTMLAttributes to add anchor specific properties like href to prop types of Link. Otherwise tsc fails to compile when using arguably important properties like href and target.

Derive from AnchorHTMLAttributes to add anchor specific properties like
href to prop types of Link.  Otherwise typescript fails to recognize
"href" or "target".
@eps1lon eps1lon added typescript component: link This is the name of the generic UI component, not the React module! labels Jan 15, 2019
@oliviertassinari oliviertassinari merged commit 7a43dba into mui:master Jan 16, 2019
@havenchyk
Copy link

havenchyk commented May 13, 2019

@lunaryorn @essuraj @oliviertassinari guys, seems after this PR an example from docs (<Link component='button' ...) doesn't pass type check in typescript.

Link component='button' is allowed as I see in sources

Here is a demo with in TS https://codesandbox.io/s/728zylw051

would you like to accept a PR with a fix?

image

@eps1lon
Copy link
Member

eps1lon commented May 13, 2019

@havenchyk This is likely fixed in 4.0.0-beta.2 since we run type-check our demos. Could you verify if you can reproduce this with the latest beta version? If so please open a separate issue.

@havenchyk
Copy link

@eps1lon it works like a charm with 4.0.0-beta.2, but shouldn't we have this fixed for the next minor version of 3.9?

@eps1lon
Copy link
Member

eps1lon commented May 13, 2019

@eps1lon it works like a charm with 4.0.0-beta.2, but shouldn't we have this fixed for the next minor version of 3.9?

Unfortunately there's no good solution that doesn't introduce a breaking change. You can search the pull request for "generic props" to get a better understanding of the issue.

@havenchyk
Copy link

@eps1lon I'm sorry for asking here, but I can't find a way to define a type of component prop :(

It's generic in Link.d.ts, I want to pass this component value from a wrapper component in TS, maybe you can help with the resulted type of a component prop?

@eps1lon
Copy link
Member

eps1lon commented May 14, 2019

@havenchyk Have you checked out https://next.material-ui.com/components/links/#third-party-routing-library (open code and switch to the TS version). If this doesn't work please open a separate issue and follow the issue template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: link This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants