Make 'Omit' a distributive conditional type to support union prop types. Fixes #39300. (#39323)

This commit is contained in:
Clay Miller
2019-10-28 11:11:25 +09:00
committed by Jessica Franco
parent 46322caeb1
commit f71b4a0526
2 changed files with 2 additions and 3 deletions
+1 -1
View File
@@ -346,7 +346,7 @@ export type ThemedCssFunction<T extends object> = BaseThemedCssFunction<
>;
// Helper type operators
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type Omit<T, K extends keyof T> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
type WithOptionalTheme<P extends { theme?: T }, T> = Omit<P, "theme"> & {
theme?: T;
};
+1 -2
View File
@@ -1052,8 +1052,7 @@ function unionTest() {
font-size: ${props => props.kind === 'book' ? 16 : 14}
`;
// undesired, fix was reverted because of https://github.com/Microsoft/TypeScript/issues/30663
<StyledReadable kind="book" author="Hejlsberg" />; // $ExpectError
<StyledReadable kind="book" author="Hejlsberg" />;
<StyledReadable kind="magazine" author="Hejlsberg" />; // $ExpectError
}