Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RyanCavanaugh opened this issue May 30, 2023 · 5 comments
Open

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

RyanCavanaugh opened this issue May 30, 2023 · 5 comments
Labels
Docs The issue relates to how you learn TypeScript

Comments

@RyanCavanaugh
Copy link
Member

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] };
@RyanCavanaugh RyanCavanaugh added the Docs The issue relates to how you learn TypeScript label May 30, 2023
@RyanCavanaugh RyanCavanaugh changed the title Handbook should recommend better Omit Handbook should recommend using a user-defined homomorphic Omit May 30, 2023
@Andarist
Copy link
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.

@fatcerberus
Copy link

insert Spiderman meme here

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

@Andarist
Copy link
Contributor

Two Spidermans pointing at each other and both saying 'You add it' to the other one

@jdalrymple
Copy link

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

@m93a
Copy link

m93a commented Jul 24, 2024

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
Labels
Docs The issue relates to how you learn TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants