1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
=== tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts ===
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
>Omit : Omit<T, K>
type Shared< // Circularly self constraining type, defered thanks to mapping
>Shared : Shared<InjectedProps, DecorationTargetProps>
InjectedProps,
DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps>
> = {
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
};
interface ComponentClass<P> {
defaultProps?: Partial<P>; // Inference target is also mapped _and_ optional
>defaultProps : Partial<P> | undefined
}
interface InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> {
<P extends Shared<TInjectedProps, P>>(
component: ComponentClass<P>
>component : ComponentClass<P>
): ComponentClass<Omit<P, keyof Shared<TInjectedProps, P>> & TNeedsProps> & { WrappedComponent: ComponentClass<P> }
>WrappedComponent : ComponentClass<P>
} // Then intersected with and indexed via Omit and &
interface Connect { // Then strictly compared with another signature in its context
<TStateProps, TOwnProps>(
mapStateToProps: unknown,
>mapStateToProps : unknown
): InferableComponentEnhancerWithProps<TStateProps, TOwnProps>;
<TDispatchProps, TOwnProps>(
mapStateToProps: null | undefined,
>mapStateToProps : null | undefined
>null : null
mapDispatchToProps: unknown,
>mapDispatchToProps : unknown
mergeProps: null | undefined,
>mergeProps : null | undefined
>null : null
options: unknown
>options : unknown
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
}
declare var connect: Connect;
>connect : Connect
const myStoreConnect: Connect = function(
>myStoreConnect : Connect
>function( mapStateToProps?: any, mapDispatchToProps?: any, mergeProps?: any, options: unknown = {},) { return connect( mapStateToProps, mapDispatchToProps, mergeProps, options, );} : <TStateProps, TOwnProps>(mapStateToProps?: any, mapDispatchToProps?: any, mergeProps?: any, options?: unknown) => InferableComponentEnhancerWithProps<TStateProps, Omit<P, Extract<keyof TStateProps, keyof P>> & TOwnProps>
mapStateToProps?: any,
>mapStateToProps : any
mapDispatchToProps?: any,
>mapDispatchToProps : any
mergeProps?: any,
>mergeProps : any
options: unknown = {},
>options : unknown
>{} : {}
) {
return connect(
>connect( mapStateToProps, mapDispatchToProps, mergeProps, options, ) : InferableComponentEnhancerWithProps<TStateProps, Omit<P, Extract<keyof TStateProps, keyof P>> & TOwnProps>
>connect : Connect
mapStateToProps,
>mapStateToProps : any
mapDispatchToProps,
>mapDispatchToProps : any
mergeProps,
>mergeProps : any
options,
>options : unknown
);
};
export {};
|