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 96
|
=== tests/cases/compiler/genericFunctionInference2.ts ===
// Repro from #30685
type Reducer<S> = (state: S) => S;
>Reducer : Reducer<S>
>state : S
declare function combineReducers<S>(reducers: { [K in keyof S]: Reducer<S[K]> }): Reducer<S>;
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S>
>reducers : { [K in keyof S]: Reducer<S[K]>; }
type MyState = { combined: { foo: number } };
>MyState : { combined: { foo: number;}; }
>combined : { foo: number; }
>foo : number
declare const foo: Reducer<MyState['combined']['foo']>;
>foo : Reducer<number>
const myReducer1: Reducer<MyState> = combineReducers({
>myReducer1 : Reducer<MyState>
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: number; }; }>
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S>
>{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; }
combined: combineReducers({ foo }),
>combined : Reducer<{ foo: number; }>
>combineReducers({ foo }) : Reducer<{ foo: number; }>
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S>
>{ foo } : { foo: Reducer<number>; }
>foo : Reducer<number>
});
const myReducer2 = combineReducers({
>myReducer2 : Reducer<{ combined: { foo: number; }; }>
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: number; }; }>
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S>
>{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; }
combined: combineReducers({ foo }),
>combined : Reducer<{ foo: number; }>
>combineReducers({ foo }) : Reducer<{ foo: number; }>
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S>
>{ foo } : { foo: Reducer<number>; }
>foo : Reducer<number>
});
// Repro from #30942
declare function withH<T, U>(handlerCreators: HandleCreatorsFactory<T, U>): U;
>withH : <T, U>(handlerCreators: HandleCreatorsFactory<T, U>) => U
>handlerCreators : HandleCreatorsFactory<T, U>
type Props = { out: number }
>Props : { out: number; }
>out : number
type HandleCreatorsFactory<T, U> = (initialProps: T) => { [P in keyof U]: (props: T) => U[P] };
>HandleCreatorsFactory : HandleCreatorsFactory<T, U>
>initialProps : T
>props : T
const enhancer4 = withH((props: Props) => ({
>enhancer4 : { onChange: (e: any) => void; onSubmit: (e: any) => void; }
>withH((props: Props) => ({ onChange: (props) => (e: any) => {}, onSubmit: (props) => (e: any) => {},})) : { onChange: (e: any) => void; onSubmit: (e: any) => void; }
>withH : <T, U>(handlerCreators: HandleCreatorsFactory<T, U>) => U
>(props: Props) => ({ onChange: (props) => (e: any) => {}, onSubmit: (props) => (e: any) => {},}) : (props: Props) => { onChange: (props: Props) => (e: any) => void; onSubmit: (props: Props) => (e: any) => void; }
>props : Props
>({ onChange: (props) => (e: any) => {}, onSubmit: (props) => (e: any) => {},}) : { onChange: (props: Props) => (e: any) => void; onSubmit: (props: Props) => (e: any) => void; }
>{ onChange: (props) => (e: any) => {}, onSubmit: (props) => (e: any) => {},} : { onChange: (props: Props) => (e: any) => void; onSubmit: (props: Props) => (e: any) => void; }
onChange: (props) => (e: any) => {},
>onChange : (props: Props) => (e: any) => void
>(props) => (e: any) => {} : (props: Props) => (e: any) => void
>props : Props
>(e: any) => {} : (e: any) => void
>e : any
onSubmit: (props) => (e: any) => {},
>onSubmit : (props: Props) => (e: any) => void
>(props) => (e: any) => {} : (props: Props) => (e: any) => void
>props : Props
>(e: any) => {} : (e: any) => void
>e : any
}));
enhancer4.onChange(null);
>enhancer4.onChange(null) : void
>enhancer4.onChange : (e: any) => void
>enhancer4 : { onChange: (e: any) => void; onSubmit: (e: any) => void; }
>onChange : (e: any) => void
>null : null
|