Skip to content

Instantly share code, notes, and snippets.

@PhoneDroid
Created September 5, 2023 12:51
Show Gist options
  • Select an option

  • Save PhoneDroid/e013bbb61c323bb774b974d7b83790f5 to your computer and use it in GitHub Desktop.

Select an option

Save PhoneDroid/e013bbb61c323bb774b974d7b83790f5 to your computer and use it in GitHub Desktop.

Partials

Makes a given union of keys partial.


type Partials < Type , Keys extends keyof Type = keyof Type > = 
    & Partial<Pick<Type,Keys>> 
    & Pick<Type,Exclude<keyof Type,Keys>>

interface A {
    a : string
    b : string
}

type B = Partials<A,'a'>

interface B {
    a ?: string
    b : string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment