-
Notifications
You must be signed in to change notification settings - Fork 252
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
feature request: add first class support for filtering HTMLAttributes #151
Comments
Looking at the // styleguide.config.js
// ...
module.exports = {
propsParser: reactDocgenTypescript.withCustomConfig('./tsconfig.json', {
propFilter(prop, component) {
debugger
return true
}
}).parse,
// ...
} When debugging, it looks like > prop.parent
{ fileName: 'baby-registry-components/node_modules/@types/react/index.d.ts',
name: 'HTMLAttributes' } One could use that to conditionally return based on the definition file's path. |
is it recursive? perhaps this lib could expose a composable filter function? const { withHtmlAttributesFilter } = require(...)
// case 1
module.exports = {
propsParser: reactDocgenTypescript.withCustomConfig('./tsconfig.json', {
propFilter: withHtmlAttributesFilter
}).parse,
}
// case 2
module.exports = {
propsParser: reactDocgenTypescript.withCustomConfig('./tsconfig.json', {
propFilter: withHtmlAttributesFilter((prop, filter) => {
// your other filters
})
}).parse,
} |
This // styleguide.config.js
// ...
module.exports = {
propsParser: reactDocgenTypescript.withCustomConfig('./tsconfig.json', {
propFilter(prop) {
if (prop.parent) {
return !prop.parent.fileName.includes('node_modules')
}
return true
},
}).parse,
// ...
} Only outputs the component's own props. Could we perhaps modify the Readme so other users know about this? |
I encountered the problem. |
@ejuo I'm also experiencing this issue as our project is also using TypeScript 3.5.0 is your workaround just to downgrade the version of TS? |
Is there a workaround for this? |
This doesn't seem to work if my props are named with names like |
seems like this one can be closed @pvasek |
problem
often times, one defines an a prop interface by extending HTML attributes, e.g
React.ReactNode<HTMLInputAttributes>
.e.g.
consequently, the styleguidist prop types generates prop documentation for all of the HTML attributes, not simply
bestProp
.discussion
thoughts? thanks!
The text was updated successfully, but these errors were encountered: