Skip to content

Add Omit<T,K> and Diff<T,U> to lib.d.ts #19569

Closed
@Pajn

Description

@Pajn

As spread and rest types is taking time I usually have to copy these types in projects. They solve the primary use case for spread/rest types and works today. I think they should fit right in next to Pick and Partial.
And even when (if?) spread and rest types is merged these would still arguably have some value.

export type Diff<T extends string, U extends string> = ({[P in T]: P} &
  {[P in U]: never} & {[x: string]: never})[T]
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions