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

The problem with Omit utility type #56284

Closed
5 tasks done
Gautamvaishnav-git opened this issue Nov 1, 2023 · 3 comments
Closed
5 tasks done

The problem with Omit utility type #56284

Gautamvaishnav-git opened this issue Nov 1, 2023 · 3 comments
Labels
Unactionable There isn't something we can do with this issue

Comments

@Gautamvaishnav-git
Copy link

πŸ” Search Terms

When we use Omit utility type we don't get auto-completion like we have in pick.

βœ… Viability Checklist

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals

⭐ Suggestion

I just created my own utility type called OmitKeys

type OmitKeys<Type, K extends keyof Type> = Omit<Type, K>

πŸ“ƒ Motivating Example

type A = {
    name: string,
    age: number,
    class: string
}


type OmitKeys<Type, K extends keyof Type> = Omit<Type, K>

type a = OmitKeys<A, "age" | "name">

πŸ’» Use Cases

  1. What do you want to use this for?
  2. What shortcomings exist with current approaches?
  3. What workarounds are you using in the meantime?
@MartinJohns
Copy link
Contributor

MartinJohns commented Nov 1, 2023

πŸ” Search Terms

When we use Omit utility type we don't get auto-completion like we have in pick.

Try using keywords as search terms, then you might have better luck finding the duplicates.


You didn't fill out the issue template, so it's unclear what you're actually suggesting. Under "Suggestion" you just wrote "I created my own type", nothing more.

If you're suggesting to change Omit<> to use keyof T, then it's a duplicate of #30825 (and many many others). If you're suggesting to add the OmitKeys<> type to the standard library, then it's out of scope as the team decided to not add further utility types unless they're needed for emit purposes (see #55746).

@fatcerberus
Copy link

Also see #54451

@RyanCavanaugh RyanCavanaugh added the Unactionable There isn't something we can do with this issue label Nov 1, 2023
@RyanCavanaugh
Copy link
Member

Duplicate #56135? But it's hard to tell what you want here without filling out the template more concretely.

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unactionable There isn't something we can do with this issue
Projects
None yet
Development

No branches or pull requests

4 participants