We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently, if a union type is given to Omit, the returned type does not correctly preserve the union type, e.g. this test fails:
Omit
declare const foo: Omit<{ shared: string; } & ({ x: boolean } | { y: string }), 'shared'>; /* $ExpectType Pick<{ shared: string; } & { x: boolean; }, "x"> | Pick<{ shared: string; } & { y: string; }, "y"> */ foo;
foo instead has type
foo
Pick<({ shared: string; } & { x: boolean; }) | ({ shared: string; } & { y: string; }), never>
We can use conditional types to fix this:
export type Omit<T, K extends keyof any> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
microsoft/TypeScript#12215 (comment)
We might also want to apply this fix to some of the other helpers?
The text was updated successfully, but these errors were encountered:
@OliverJAsh sounds good, want to open a PR?
Sorry, something went wrong.
47e52e0
No branches or pull requests
Currently, if a union type is given to
Omit
, the returned type does not correctly preserve the union type, e.g. this test fails:foo
instead has typeWe can use conditional types to fix this:
microsoft/TypeScript#12215 (comment)
We might also want to apply this fix to some of the other helpers?
The text was updated successfully, but these errors were encountered: