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

Fix: wrong generic type of Omit #35462

Closed
wants to merge 1 commit into from
Closed

Fix: wrong generic type of Omit #35462

wants to merge 1 commit into from

Conversation

nnnnnoel
Copy link

@nnnnnoel nnnnnoel commented Dec 3, 2019

No description provided.

@typescript-bot
Copy link
Collaborator

It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'.

@typescript-bot typescript-bot added the lib update PR modifies files in the `lib` folder label Dec 3, 2019
@weswigham
Copy link
Member

weswigham commented Dec 3, 2019

Nah, the current formulation is intentional. Omit's second argument doesn't need to be limited to the keys of its' first, as the operation works fine if there're not (Omit<{x: number}, "y"> can still be resolved), so it isn't. keyof any is just used as a way to say "all key types" (string | number | symbol).

Notably, the current formulation lets you do thing like Omit<{x: number, y: number}, "y" | "z"> (which is to say, elide partially overlapping sets of properties) which would otherwise fail, but are incredibly useful.

@weswigham weswigham closed this Dec 3, 2019
@weswigham
Copy link
Member

See #30825 for more on this.

@nnnnnoel nnnnnoel deleted the patch-1 branch December 4, 2019 04:46
@nnnnnoel
Copy link
Author

But we can make StirctOmit<T, U extends keyof T> right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib update PR modifies files in the `lib` folder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants