-
-
Notifications
You must be signed in to change notification settings - Fork 538
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 ConditionalKeys - prevent never from being included unintentionally #881
Fix ConditionalKeys - prevent never from being included unintentionally #881
Conversation
The only thing that's a bit funky with this implementation is that it doesn't work if the condition you're trying to target is type MyMap = {
a: {
b: string;
};
c: {
html: string;
};
d: never;
};
type MyFilteredMap = ConditionalKeys<MyMap, never>; |
Ok, updated it to work for targeting |
source/conditional-keys.d.ts
Outdated
// Discard this key since the condition fails. | ||
// Retain this key since the condition passes | ||
? | ||
// If the condition extends never, only include the key if the value for that key is also never |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know if you want to format this differently. I chose to progressively increase indentation for each level of ternary, and to keep comments indented to the same level as the line they're describing.
Fixes #878
The following minimal example doesn't work as expected with the minimal example, because it includes
d
in the result, even though the value isnever