Skip to content

Handbook should recommend using a user-defined homomorphic Omit #54451

Description

Bug Report

Per #53188, we know that it'd be better if Omit were homomorphic. In the Handbook we should steer people toward a better user definition, e.g.

type MappedOmit<T, K extends keyof T> = { [P in keyof T as P extends K ? never : P]: T[P] };

Activity

  1. changed the title [-]Handbook should recommend better `Omit`[/-] [+]Handbook should recommend using a user-defined homomorphic `Omit`[/+] on May 30, 2023
  2. Andarist commented on May 31, 2023

    @Andarist
    Contributor

    From the user's perspective, it really feels weird to me that this is pushed into the userland.

    I totally understand the argument behind not wanting to make changes to the existing Omit. You are concerned with having 2 Omits in the lib files which is also somewhat understandable. It's hard to come up with a perfect name for this, it also might confuse some people. But isn't including this in the handbook already (a) giving this a name, (b) might confuse some people? Shifting the responsibility for defining this type in the userland feels a little bit like a hygiene theater thing to me. (insert Spiderman meme here)

    I also wonder what happened to destructure improvements related to MappedOmit from #53134 ? This PR has been closed without any concrete conclusion about that part and the related design notes also don't address this explicitly anyhow.

  3. fatcerberus commented on May 31, 2023

    @fatcerberus

    insert Spiderman meme here

    There are a few of these. Which one are you referencing?

  4. Andarist commented on May 31, 2023

    @Andarist
    Contributor
    Two Spidermans pointing at each other and both saying 'You add it' to the other one
  5. jdalrymple commented on Jun 6, 2023

    @jdalrymple

    Type-fest has a similar function, which is named "Except" which would avoid confusion with the same name?

  6. cshaa commented on Jul 24, 2024

    @cshaa

    I think something like Except should be added to the standard library and Omit should be marked as deprecated, as it's quite the footgun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsThe issue relates to how you learn TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions