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

Omit not providing intellisense on what can be omitted from type #56135

Closed
1 task done
Daggron opened this issue Oct 17, 2023 · 5 comments
Closed
1 task done

Omit not providing intellisense on what can be omitted from type #56135

Daggron opened this issue Oct 17, 2023 · 5 comments
Labels
Not a Defect This behavior is one of several equally-correct options

Comments

@Daggron
Copy link

Daggron commented Oct 17, 2023

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Description

  • When I am using Omit it takes two parameters

    1. The object type from which the keys are to be omitted
    2. The keys which we want to remove.
  • Now when I try to do this I get no intellisense / autocompletion that hey these are the keys which are present in the Object type.

Reproduction

This can be reproduce in the this ts playground link

Screen shot for reference
Screenshot 2023-10-17 at 6 24 35 PM

Solution

type BetterOmit<T extends Record<any, any>, K extends keyof T> = {
    [P in T as P extends K ? never : P]: T[P]
}

All we need to do is add extends clause to the second Param which will give intellisense.

I can add this to the repo but need suggestion or reasoning behind the current implementation

@nmain
Copy link

nmain commented Oct 17, 2023

See #30825, #54451, #53169

@RyanCavanaugh
Copy link
Member

Omit isn't constrained on K (this is intentional), so there's no information to provide that hint from

@RyanCavanaugh RyanCavanaugh added the Not a Defect This behavior is one of several equally-correct options label Oct 17, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2023
@dnistreanu-diffco
Copy link

dnistreanu-diffco commented Apr 25, 2024

This should be a bug. Please reopen and fix it. It makes no sense to have no intelisense on Omit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Defect This behavior is one of several equally-correct options
Projects
None yet
Development

No branches or pull requests

5 participants