Created
January 27, 2022 13:27
-
-
Save Under-Warz/19bfba0b0d1b23adb0fbd44010d821c3 to your computer and use it in GitHub Desktop.
create ContainerProps type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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