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

InputSwitch: InputSwitchProps says incompatible type #2876

Closed
smasilamani-cfins opened this issue May 11, 2022 · 1 comment · Fixed by #2877
Closed

InputSwitch: InputSwitchProps says incompatible type #2876

smasilamani-cfins opened this issue May 11, 2022 · 1 comment · Fixed by #2877
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component. Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@smasilamani-cfins
Copy link

Describe the bug

We have a component that uses InputSwitch as one of the element and when we try to pass the InputSwitchProps, we are getting below error.

Interface:

export interface IDSPOBoxSwitchProps {
	textContent?: JSX.Element;
	switchProps?: InputSwitchProps;
}

Code that uses the interface is now throwing the error. (here poBoxswitchProps is of type IDSPOBoxSwitchProps )

<>
			<div className='ds-stack-h-2 fullWidth'>
				{showPOBox && (
					<div className='fullWidth block'>
						{poBoxswitchProps?.textContent || DEFUALT_PO_BOX_CONTENT}
						<InputSwitch className='mb-1' {...poBoxswitchProps?.switchProps} />
					</div>
				)}
</>

Error:

No overload matches this call.
Overload 1 of 2, '(props: InputSwitchProps | Readonly): InputSwitch', gave the following error.
Type '{ id?: string; inputRef?: Ref; style?: object; className: string; inputId?: string; name?: string; tabIndex?: number; checked?: any; trueValue?: any; falseValue?: any; ... 283 more ...; onTransitionEndCapture?: TransitionEventHandler<...>; }' is not assignable to type 'IntrinsicClassAttributes'.
Types of property 'ref' are incompatible.
Type 'LegacyRef' is not assignable to type 'LegacyRef'.
Type '(instance: HTMLDivElement) => void' is not assignable to type 'LegacyRef'.
Type '(instance: HTMLDivElement) => void' is not assignable to type '(instance: InputSwitch) => void'.
Types of parameters 'instance' and 'instance' are incompatible.
Type 'Component<InputSwitchProps, any, any>' is missing the following properties from type 'HTMLDivElement': align, addEventListener, removeEventListener, accessKey, and 278 more.
Overload 2 of 2, '(props: InputSwitchProps, context: any): InputSwitch', gave the following error.
Type '{ id?: string; inputRef?: Ref; style?: object; className: string; inputId?: string; name?: string; tabIndex?: number; checked?: any; trueValue?: any; falseValue?: any; ... 283 more ...; onTransitionEndCapture?: TransitionEventHandler<...>; }' is not assignable to type 'IntrinsicClassAttributes'.
Types of property 'ref' are incompatible.
Type 'LegacyRef' is not assignable to type 'LegacyRef'.ts(2769)

Reproducer

No response

PrimeReact version

8.0.1

React version

18.x

Language

TypeScript

Build / Runtime

Next.js

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@smasilamani-cfins smasilamani-cfins added the Type: Bug Issue contains a defect related to a specific component. label May 11, 2022
@melloware melloware added Typescript Issue or pull request is *only* related to TypeScript definition and removed Type: Bug Issue contains a defect related to a specific component. labels May 11, 2022
melloware added a commit to melloware/primereact that referenced this issue May 11, 2022
@melloware melloware self-assigned this May 11, 2022
@melloware melloware added this to the 8.1.0 milestone May 11, 2022
@melloware
Copy link
Member

Thanks for the report.

@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label May 12, 2022
@mertsincan mertsincan modified the milestones: 8.1.0, 8.1 May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component. Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants