Skip to content

Commit 56520da

Browse files
committed
Add regression tests
1 parent 8f15a2e commit 56520da

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,37 @@ let y1 = foo1(sx); // string
5454

5555
let x2 = foo2(sa); // unknown
5656
let y2 = foo2(sx); // { extra: number }
57+
58+
// Repro from #33490
59+
60+
declare class Component<P> { props: P }
61+
62+
export type ComponentClass<P> = new (props: P) => Component<P>;
63+
export type FunctionComponent<P> = (props: P) => null;
64+
65+
export type ComponentType<P> = FunctionComponent<P> | ComponentClass<P>;
66+
67+
export interface RouteComponentProps { route: string }
68+
69+
declare function withRouter<
70+
P extends RouteComponentProps,
71+
C extends ComponentType<P>
72+
>(
73+
component: C & ComponentType<P>
74+
): ComponentClass<Omit<P, keyof RouteComponentProps>>;
75+
76+
interface Props extends RouteComponentProps { username: string }
77+
78+
declare const MyComponent: ComponentType<Props>;
79+
80+
withRouter(MyComponent);
81+
82+
// Repro from #33490
83+
84+
type AB<T> = { a: T } | { b: T };
85+
86+
// T & AB<U> normalizes to T & { a: U } | T & { b: U } below
87+
declare function foo<T, U>(obj: T & AB<U>): [T, U];
88+
declare let ab: AB<string>;
89+
90+
let z = foo(ab); // [AB<string>, string]

0 commit comments

Comments
 (0)