* When noImplicitAny is set, combine multiple contextual overloads into a single signature, rather than producing `any` and an error * Amalgamate intersection composite signature return types as intersections, rather than the prior exclusively union behavior * Add another example from an issue, albeit slightly modified * Fix newlines, add test from DT * Interior remodelling
96 lines
3 KiB
Plaintext
96 lines
3 KiB
Plaintext
=== 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 {};
|
|
|