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

Trying to figure out the types for the style object in 'renderThumbVertical' #38

Open
mdodge-ecgrow opened this issue Apr 20, 2023 · 1 comment

Comments

@mdodge-ecgrow
Copy link

mdodge-ecgrow commented Apr 20, 2023

I'm struggling here to figure out the correct types for the style object that gets passed to renderThumbVertical.
This is my current code:

...
type ThumbVerticalBaseStyles = {
		backgroundColor: string;
		borderRadius: string;
		cursor: string;
		display: string;
		height: string;
		position: string;
	};
	const thumbVertical = ({
		style = {} as ThumbVerticalBaseStyles,
		...props
	}) => {
		const finalStyle = {
			...style,
			visibility: 'hidden'
		};

		return <div style={finalStyle} {...props} />;
	};

	return (
		<div className={'table-container wide'}>
			<header>
				<h3>{customers.length} Customers</h3>
			</header>
			<Scrollbars
				autoHeight
				autoHeightMin={0}
				autoHeightMax={'calc(100vh - 40px)'}
				renderThumbVertical={thumbVertical}
...

Now on that line return <div style={finalStyle} {...props} />;,
I am getting the following error: TS2322: Type '{ visibility: string; backgroundColor: string; borderRadius: string; cursor: string; display: string; height: string; position: string; }' is not assignable to type 'Properties<string | number, string & {}>'.   Types of property 'position' are incompatible.     Type 'string' is not assignable to type 'Position | undefined'. index.d.ts(1850, 9): The expected type comes from property 'style' which is declared here on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'

@JhonSJ
Copy link

JhonSJ commented Sep 6, 2023

@mdodge-ecgrow Your type for the position property is string but, the style property has the type position as Position | undefined, change your type or use CSSProperties

type ThumbVerticalBaseStyles = {
	backgroundColor: string;
	borderRadius: string;
	cursor: string;
	display: string;
	height: string;
	**position: string;**
};

type ThumbVerticalBaseStyles = React.CSSProperties;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants