Skip to content

Instantly share code, notes, and snippets.

@karlhorky
Last active March 18, 2020 17:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlhorky/ed11c5c64be5eda0b59ab2b8c4e9ff8f to your computer and use it in GitHub Desktop.
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
// 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