type ComponentType = (...args: any) => any;
type PlatformNotificationProps<TIcon extends ComponentType = ComponentType> = {
component: TIcon;
arg: Parameters<TIcon>[0];
};
const PlatformNotification = (props: PlatformNotificationProps) => {};
const Icon = (name: string) => '';
const result = PlatformNotification({
component: Icon,
arg: 100,
});
For this specific scenario, either the 'arg' value should be a string instead of a number, or the component should accept a number as an argument instead of a string. I was anticipating to receive an error in the console due to this discrepancy, but surprisingly everything is functioning fine.
What would be the proper way to define types for this particular situation?