Ability to exclude some chained prop types
See original GitHub issueIs your feature request related to a problem? Please describe. I am trying to generate docs for a library and suddenly I got into a problem where I can’t exclude some inherited types (props) from TypeScript.
TypeScript types:
type ContentProps = {
icon?: ReactNode | null;
iconPosition?: string;
children?: any;
};
export type Props = ButtonHTMLAttributes<HTMLButtonElement> &
ContentProps & {
buttonModifiers?: Array<string>;
sizeType?: Size;
style?: CSSProperties;
className?: string;
fullWidth?: boolean;
fullHeight?: boolean;
};
Button Component:
const Button = (props: Props) => ()
Describe the solution you’d like
I want to be able to remove the props from HTMLButtonElement
so it shows only the ContentProps
and the other defined props (buttonModifiers
,sizeType
etc).
Describe alternatives you’ve considered None.
Are you able to assist bring the feature to reality? maybe …
Screenshot
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Notes on TypeScript: Inferring React PropTypes
I think the problem in this specific case is tied to using forwardRef . Will try to find out in more detail ,...
Read more >Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >Section 2: Excluding Props - React TypeScript Cheatsheets
The problem we want to solve is having the HOC-wrapped-component exposing a type that reflects the reduced surface area of props - without...
Read more >You Might Not Need PropTypes in React - ITNEXT
In short, ARCcore Filter is similar to PropTypes except that it is a more general solution and data validation is performed in a...
Read more >Inheritance and the prototype chain - JavaScript | MDN
We will discuss the prototype property of constructor functions in ... To use the new operator, call the function normally except prefix it ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A workaround I’ve added is the ability to specify props
include
andexclude
:So you could achieve what you want by only including non-chained props. E.g.:
@mustran Either 6.0, which should be stable by mid-May, or 6.1, which should be stable mid-Summer.