-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[docs-infra] Fix duplicate JSDoc in proptypes generation for merged declarations #48296
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import * as React from 'react'; | ||
| import type { ComponentProps } from './types'; | ||
|
|
||
| export default function Component(props: ComponentProps) { | ||
| const { name, onItemClick } = props; | ||
|
|
||
| return <button onClick={(e) => onItemClick?.(e.nativeEvent)}>{name}</button>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import * as React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| function Component(props) { | ||
| const { name, onItemClick } = props; | ||
| return <button onClick={(e) => onItemClick?.(e.nativeEvent)}>{name}</button>; | ||
| } | ||
|
|
||
| Component.propTypes = { | ||
| /** | ||
| * A normal prop. | ||
| */ | ||
| name: PropTypes.string.isRequired, | ||
| /** | ||
| * Augmented description of the callback. | ||
| * @param {MouseEvent | React.MouseEvent} event The event source (augmented). | ||
| */ | ||
| onItemClick: PropTypes.func, | ||
|
Comment on lines
+13
to
+17
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose this is "somewhat correct"? Like, the real ts implementation resolves to different overloads (because it is an interface with functions), for natives objects it still merges the docs. I've added more examples to the ts playground But since proptypes will likely only care for the most complete, I guess in this case it makes sense to pick last?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can refine this further as need arises. But this change doesnt affect anything in core and in X only 3-4 files are affected. |
||
| }; | ||
|
|
||
| export default Component; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| export interface ComponentProps { | ||
| /** | ||
| * Original description of the callback. | ||
| * @param {MouseEvent} event The event source. | ||
| */ | ||
| onItemClick?(event: MouseEvent): void; | ||
| /** | ||
| * A normal prop. | ||
| */ | ||
| name: string; | ||
| } | ||
|
|
||
| // Module augmentation / declaration merging | ||
| export interface ComponentProps { | ||
| /** | ||
| * Augmented description of the callback. | ||
| * @param {MouseEvent | React.MouseEvent} event The event source (augmented). | ||
| */ | ||
| onItemClick?(event: MouseEvent | React.MouseEvent): void; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| interface BaseProps { | ||
| /** | ||
| * The label from base. | ||
| * @default 'base' | ||
| */ | ||
| label: string; | ||
| /** | ||
| * If true, the component is disabled. | ||
| */ | ||
| disabled?: boolean; | ||
| } | ||
|
|
||
| interface ExtraProps { | ||
| /** | ||
| * The label from extra. | ||
| * @default 'extra' | ||
| */ | ||
| label: string; | ||
| /** | ||
| * The size of the component. | ||
| */ | ||
| size?: 'small' | 'medium' | 'large'; | ||
| } | ||
|
|
||
| interface CombinedProps extends BaseProps, ExtraProps {} | ||
|
|
||
| export default function Component(props: CombinedProps) { | ||
| const { label, disabled, size } = props; | ||
| return ( | ||
| <button disabled={disabled} data-size={size}> | ||
| {label} | ||
| </button> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import * as React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| function Component(props) { | ||
| const { label, disabled, size } = props; | ||
| return ( | ||
| <button disabled={disabled} data-size={size}> | ||
| {label} | ||
| </button> | ||
| ); | ||
| } | ||
|
|
||
| Component.propTypes = { | ||
| /** | ||
| * If true, the component is disabled. | ||
| */ | ||
| disabled: PropTypes.bool, | ||
| /** | ||
| * The label from base. | ||
| * @default 'base' | ||
| */ | ||
| label: PropTypes.string.isRequired, | ||
| /** | ||
| * The size of the component. | ||
| */ | ||
| size: PropTypes.oneOf(['large', 'medium', 'small']), | ||
| }; | ||
|
|
||
| export default Component; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| interface BaseProps { | ||
| /** | ||
| * The label from base. | ||
| * @default 'base' | ||
| */ | ||
| label: string; | ||
| /** | ||
| * If true, the component is disabled. | ||
| */ | ||
| disabled?: boolean; | ||
| } | ||
|
|
||
| interface OverrideProps extends BaseProps { | ||
| /** | ||
| * The overridden label description. | ||
| * @default 'override' | ||
| */ | ||
| label: string; | ||
| } | ||
|
|
||
| export default function Component(props: OverrideProps) { | ||
| const { label, disabled } = props; | ||
| return <button disabled={disabled}>{label}</button>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import * as React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| function Component(props) { | ||
| const { label, disabled } = props; | ||
| return <button disabled={disabled}>{label}</button>; | ||
| } | ||
|
|
||
| Component.propTypes = { | ||
| /** | ||
| * If true, the component is disabled. | ||
| */ | ||
| disabled: PropTypes.bool, | ||
| /** | ||
| * The overridden label description. | ||
| * @default 'override' | ||
| */ | ||
| label: PropTypes.string.isRequired, | ||
| }; | ||
|
|
||
| export default Component; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| type BaseProps = { | ||
| /** | ||
| * The label of the component. | ||
| * @default 'base' | ||
| */ | ||
| label: string; | ||
| /** | ||
| * If true, the component is disabled. | ||
| */ | ||
| disabled?: boolean; | ||
| }; | ||
|
|
||
| type ExtraProps = { | ||
| /** | ||
| * The label from extra props. | ||
| * @default 'extra' | ||
| */ | ||
| label: string; | ||
| /** | ||
| * The size of the component. | ||
| */ | ||
| size?: 'small' | 'medium' | 'large'; | ||
| }; | ||
|
|
||
| type CombinedProps = BaseProps & ExtraProps; | ||
|
|
||
| export default function Component(props: CombinedProps) { | ||
| const { label, disabled, size } = props; | ||
| return ( | ||
| <button disabled={disabled} data-size={size}> | ||
| {label} | ||
| </button> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import * as React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| function Component(props) { | ||
| const { label, disabled, size } = props; | ||
| return ( | ||
| <button disabled={disabled} data-size={size}> | ||
| {label} | ||
| </button> | ||
| ); | ||
| } | ||
|
|
||
| Component.propTypes = { | ||
| /** | ||
| * If true, the component is disabled. | ||
| */ | ||
| disabled: PropTypes.bool, | ||
| /** | ||
| * The label of the component. | ||
| * @default 'base' | ||
| * The label from extra props. | ||
| * @default 'extra' | ||
| */ | ||
| label: PropTypes.string.isRequired, | ||
| /** | ||
| * The size of the component. | ||
| */ | ||
| size: PropTypes.oneOf(['large', 'medium', 'small']), | ||
| }; | ||
|
|
||
| export default Component; |
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.
Is this comment not valid anymore?