-
Notifications
You must be signed in to change notification settings - Fork 208
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
typing?
#495
Comments
|
Now I remember why the type definition is like that. In the examples of the package you can find |
@Masa-Shin Okay but then why isn't
function pick<T, U extends keyof T>(obj: T, select: U[]): Pick<T, U>; And there's also an example like the one you mentioned for pick(obj, ['a', 'b', 'd']); // {a: 3, b: 5} This example actually yields an error: So at the very least, these two functions need to be consistent in their typing. But I would argue This is actually how you typically handle edge cases like this in TypeScript. I would argue the library should just provide the most expected typing. |
I see your point. I made |
I think it is OK to make a PR for the issue since that for the |
Yes, exactly!
Yeah I think that makes sense, that would be great, thank you so much! :) |
Thanks @aradalvand and @Masa-Shin! PR landed |
Hi there, thanks for this immensely useful library.
The current signature of the
omit
function is as follows:This doesn't make sense, it means that you get no type-safety whatsoever when specifying the property keys, they would effectively be magic strings. Why not:
This, on the other hand, does provide type-safety and all the goodness that comes with it (e.g. code completion, etc.)
The text was updated successfully, but these errors were encountered: