Skip to content

Instantly share code, notes, and snippets.

@Under-Warz
Created January 27, 2022 13:27
Show Gist options
  • Save Under-Warz/19bfba0b0d1b23adb0fbd44010d821c3 to your computer and use it in GitHub Desktop.
Save Under-Warz/19bfba0b0d1b23adb0fbd44010d821c3 to your computer and use it in GitHub Desktop.
create ContainerProps type
/**
* Type that allows us to type component containers
* InjectedProps: The props injected by the container in the child component
* NeededProps: The Props the container needs that are not in the child component
*
* The InjectedProps object needs to be a subset of the ChildProps keys.
*/
export type ContainerProps<
ChildProps,
InjectedKeys extends keyof Partial<ChildProps>,
// eslint-disable-next-line @typescript-eslint/ban-types
NeededProps extends Record<string, unknown> = {}
> = Omit<ChildProps, InjectedKeys> & NeededProps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment