Last active
March 18, 2020 17:12
-
-
Save karlhorky/ed11c5c64be5eda0b59ab2b8c4e9ff8f to your computer and use it in GitHub Desktop.
Flow: Omit utility function to remove keys of an object type by using $Diff
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
// Source: https://github.com/facebook/flow/issues/3367#issuecomment-397933288 | |
// We can replicate $Omit non dynamic functionality by doing the following: | |
type T0 = { | |
k0: string, | |
k1: number, | |
k2: boolean | |
}; | |
// this would be the same as type T1 = $Omit<T0, ["k0", "k1"]> | |
type T1 = $Diff<T0, { | |
k0: *, | |
k1: * | |
}>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment