Skip to content

Instantly share code, notes, and snippets.

@preetjdp
Created December 10, 2020 07:48
Show Gist options
  • Save preetjdp/fa9111ed798f1becc0e90cfd98811548 to your computer and use it in GitHub Desktop.
Save preetjdp/fa9111ed798f1becc0e90cfd98811548 to your computer and use it in GitHub Desktop.
Generic Optional
// Ref -> https://github.com/Microsoft/TypeScript/issues/25760#issuecomment-614417742
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
interface User {
uuid: string
name: string
}
const createUser = (user: Optional<User, "uuid">): void => {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment