-
Notifications
You must be signed in to change notification settings - Fork 118
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
DeepExclude #184
Comments
I would love to have a DeepExclude. The above type doesn't seem to quite work yet. type O = DeepExclude<{foo: number | {bar: number}}, {bar: number}>;
|
Interesting, I did not consider that use case. It works for us on simple cases like a class or an interface. |
I already use a mapped exclude type in my project but haven't figured out how to make it fully recursive yet. I'd be curious if you come up with a recursive version that works for arrays and interfaces.
|
I asked on SO and this solution works well for me: https://stackoverflow.com/a/64900252/214950. type DeepExclude<T, U> =
T extends U ? never :
T extends object ? {
[K in keyof T]: DeepExclude<T[K], U>
} : T; |
This only works for simple objects and it wont work for arrays, sets, promises, etc. |
Hey @Sytten! Do you still find |
I dont work with typescript anymore, so for you |
Sometimes you just want to remove a type from all keys. A
DeepExclude
would be useful, something like:The text was updated successfully, but these errors were encountered: