I am struggling with repetitive code that involves a type with minor variations:
import { ComponentPropsWithRef, ElementType } from "react";
interface PackshotPropsBase {
a: string
}
interface PackshotPropsWeb {
b: string
}
export type ElementAndPackshotProps<T extends ElementType, P extends PackshotPropsBase> = Omit<
ComponentPropsWithRef<T>,
keyof P
> &
P;
export type ElementAndPackshotPropsWeb<T extends ElementType, P extends PackshotPropsWeb> = Omit<
ComponentPropsWithRef<T>,
keyof P
> &
P;
The main distinction lies in the type that P
extends. Is there a way to streamline this and create a type that extends another generic type?
Explore the TypeScript playground here.