FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add the Omit helper type by DanielRosenwasser · Pull Request #30552 · microsoft/TypeScript · GitHub

Add the Omit helper type - #30552

Merged
Daniel Rosenwasser (DanielRosenwasser) merged 4 commits into
masterfrom
omit
Apr 4, 2019
Merged

Add the Omit helper type#30552
Daniel Rosenwasser (DanielRosenwasser) merged 4 commits into
masterfrom
omit

Conversation

Copy link
Copy Markdown
Member

Fixes #30455.

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) run dt

TypeScript Bot (typescript-bot) commented Mar 22, 2019
edited
Loading

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the Definitely Typed test suite on this PR at 53e76b3. You can monitor the build here. It should now contribute to this PR's status checks.

Copy link
Copy Markdown
Member Author

The only breakages on DefinitelyTyped seem to be

  • amap-js-api
  • amap-js-api-indoor-map
  • amap-js-api-map3d

And those all really come from amap-js-api unnecessarily plopping Omit in the global scope.

Daniel Rosenwasser (DanielRosenwasser) commented Apr 3, 2019
edited
Loading

Copy link
Copy Markdown
Member Author

A fix is now out to DefinitelyTyped's amap-js-api package.

I used BigTSQuery to partially assess the breakage with the following query

SourceFile:not([externalModuleIndicator]) > TypeAliasDeclaration > Identifier[name=Omit]

BigTSQuery isn't fully up to date (Uri Shaked (@urish) out of curiosity, how recent is the dataset?), but we saw three distinct results:

Also:

Copy link
Copy Markdown
Member Author

We discussed this at #30738 and believe that the breakage can be easily communicated and is more limited than we initially anticipated.

Copy link
Copy Markdown

Keys are not limited to keyof T. Is that on purpose?

Veniamin Krol (vkrol) commented Apr 7, 2019
edited
Loading

Copy link
Copy Markdown

Aleksey Levenstein (@levenleven)

Should we constrain K in the official definition?

Nah

#30738

🤔

Copy link
Copy Markdown
Member Author

Exclude doesn't constrain its second type parameter on the first, so we felt like it would be strange to do that with Omit.

Copy link
Copy Markdown
Member Author

Note, if you feel that shouldn't be the case, I'd encourage you to open up a separate issue to discuss it.

Copy link
Copy Markdown

Daniel Rosenwasser (@DanielRosenwasser) the BigTSQuery dataset has last been updated around June 2018. If you find it useful, I can spend some time updating it

Copy link
Copy Markdown
Contributor

Can Omit please be made strict before 3.5 moves to stable? #30825

Copy link
Copy Markdown
Member

Felix Becker (@felixfbecker) the definition was intentional.

Leo Y. Li (leoyli) commented May 19, 2019
edited
Loading

Copy link
Copy Markdown

Daniel Rosenwasser (@DanielRosenwasser)

Exclude doesn't constrain its second type parameter on the first, so we felt like it would be strange to do that with Omit.

But how a bout the case of Pick? Pick do constrain the use case.

Pick: pick members from a group to get a sub-group;
Omit: omit members in a group to get a sub-group;

As you can see, these 2 helper types are somehow complimentary. Looks pretty nature and intuitive when we use them together. How come Omit being permissive and Pick isn't???

When we make comparison, compare Omit with Exclude is like compare egg with chicken. Exclude is comparable with Extract not Omit, which should be Pick, IMHO.

Copy link
Copy Markdown
Contributor

I've ran into a few bugs which would have been caught if K was constrained (like it is for Pick). Any chance of reconsidering this?

Copy link
Copy Markdown

TypeScript is not open-source, it's source-available.

Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Omit as a known interface

10 participants


Back | FazBrowse Home | New Git URL