Could someone explain why React is not interpreting a function that handles the component declaration as a extendable type attribute as a React React Function, resulting in the error: Type '[...]' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes[...]'
, but when I declare it directly in the parameter it’s interpreted as a React Function element:
type RenderComponentOptions<P> = {
Component: React.ComponentType<P>,
props: P
}
function directlyOnParameterDeclaration<Props extends {}>(
Component: React.ComponentType<Props>, props: Props
) {
return <Component {...props} />
}
function extandableFunctionAttributeDeclaration<
Props extends {},
T extends React.ComponentType<Props>
>(Component: T, props: Props) {
return <Component {...props} />
}
At the Component
usage (<Component {...props} />
at line 16) on the extandableFunctionAttributeDeclaration
function will result in this TS error:
Type 'Props' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes<T, Props>'.
Type '{}' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes<T, Props>'.
Type '{}' is not assignable to type 'LibraryManagedAttributes<T, Props>'.
Type 'Props' is not assignable to type 'LibraryManagedAttributes<T, Props>'.
Type '{}' is not assignable to type 'LibraryManagedAttributes<T, Props>'. (2322)