|
| 1 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(3,6): error TS2456: Type alias 'Shared' circularly references itself. |
| 2 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(5,35): error TS2313: Type parameter 'DecorationTargetProps' has a circular constraint. |
| 3 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(5,35): error TS2315: Type 'Shared' is not generic. |
| 4 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(7,15): error TS2313: Type parameter 'P' has a circular constraint. |
| 5 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(7,75): error TS2536: Type 'P' cannot be used to index type 'InjectedProps'. |
| 6 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(7,100): error TS2536: Type 'P' cannot be used to index type 'DecorationTargetProps'. |
| 7 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(7,127): error TS2536: Type 'P' cannot be used to index type 'DecorationTargetProps'. |
| 8 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(15,16): error TS2315: Type 'Shared' is not generic. |
| 9 | +tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts(17,37): error TS2315: Type 'Shared' is not generic. |
| 10 | + |
| 11 | + |
| 12 | +==== tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts (9 errors) ==== |
| 13 | + type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; |
| 14 | + |
| 15 | + type Shared< // Circularly self constraining type, defered thanks to mapping |
| 16 | + ~~~~~~ |
| 17 | +!!! error TS2456: Type alias 'Shared' circularly references itself. |
| 18 | + InjectedProps, |
| 19 | + DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps> |
| 20 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 21 | +!!! error TS2313: Type parameter 'DecorationTargetProps' has a circular constraint. |
| 22 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 23 | +!!! error TS2315: Type 'Shared' is not generic. |
| 24 | + > = { |
| 25 | + [P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never; |
| 26 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 27 | +!!! error TS2313: Type parameter 'P' has a circular constraint. |
| 28 | +!!! related TS2751 tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts:5:35: Circularity originates in type at this location. |
| 29 | + ~~~~~~~~~~~~~~~~ |
| 30 | +!!! error TS2536: Type 'P' cannot be used to index type 'InjectedProps'. |
| 31 | + ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 32 | +!!! error TS2536: Type 'P' cannot be used to index type 'DecorationTargetProps'. |
| 33 | + ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 34 | +!!! error TS2536: Type 'P' cannot be used to index type 'DecorationTargetProps'. |
| 35 | + }; |
| 36 | + |
| 37 | + interface ComponentClass<P> { |
| 38 | + defaultProps?: Partial<P>; // Inference target is also mapped _and_ optional |
| 39 | + } |
| 40 | + |
| 41 | + interface InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> { |
| 42 | + <P extends Shared<TInjectedProps, P>>( |
| 43 | + ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 44 | +!!! error TS2315: Type 'Shared' is not generic. |
| 45 | + component: ComponentClass<P> |
| 46 | + ): ComponentClass<Omit<P, keyof Shared<TInjectedProps, P>> & TNeedsProps> & { WrappedComponent: ComponentClass<P> } |
| 47 | + ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 48 | +!!! error TS2315: Type 'Shared' is not generic. |
| 49 | + } // Then intersected with and indexed via Omit and & |
| 50 | + |
| 51 | + interface Connect { // Then strictly compared with another signature in its context |
| 52 | + <TStateProps, TOwnProps>( |
| 53 | + mapStateToProps: unknown, |
| 54 | + ): InferableComponentEnhancerWithProps<TStateProps, TOwnProps>; |
| 55 | + |
| 56 | + <TDispatchProps, TOwnProps>( |
| 57 | + mapStateToProps: null | undefined, |
| 58 | + mapDispatchToProps: unknown, |
| 59 | + mergeProps: null | undefined, |
| 60 | + options: unknown |
| 61 | + ): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>; |
| 62 | + } |
| 63 | + |
| 64 | + declare var connect: Connect; |
| 65 | + |
| 66 | + const myStoreConnect: Connect = function( |
| 67 | + mapStateToProps?: any, |
| 68 | + mapDispatchToProps?: any, |
| 69 | + mergeProps?: any, |
| 70 | + options: unknown = {}, |
| 71 | + ) { |
| 72 | + return connect( |
| 73 | + mapStateToProps, |
| 74 | + mapDispatchToProps, |
| 75 | + mergeProps, |
| 76 | + options, |
| 77 | + ); |
| 78 | + }; |
| 79 | + |
| 80 | + export {}; |
| 81 | + |
0 commit comments