-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Using omit can't validate key passed as parameter #5884
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
Comments
It seems like the current type is |
I certainly know that I can do it, but then I cannot use Typescript's type inference adding boilerplate and making that overload useless. It would be enough one overload with any or |
I am not sure I understood, do you mean something like this: |
No. The problem is that the omit has three overloads: omit<T extends object, K extends PropertyName[]>(
object: T | null | undefined,
...paths: K
): Pick<T, Exclude<keyof T, K[number]>>;
/**
* @see _.omit
*/
omit<T extends object, K extends keyof T>(object: T | null | undefined, ...paths: Array<Many<K>>): Omit<T, K>;
/**
* @see _.omit
*/
omit<T extends object>(object: T | null | undefined, ...paths: Array<Many<PropertyName>>): PartialObject<T>; The problem is that I'd want to use the second one, without explicitly passing the generics parameters, leveraging the TS's type inference. At the moment with this three overload instead you don't have any intellisense and if you pass any key that is not in the object keys it compiles. Therefore this solution is not robust and expose you to risk in case of refactoring of the property names. |
Where for I omit that |
It seems that generic omit overloads prevent the usage of the typed one that connect the object type to the type of keys
The text was updated successfully, but these errors were encountered: