TypeScript Version: 4.0.5
Search Terms:
infer, object literals, interdependencies
Code
typeSelector<S>=(state: S)=>anyexportinterfaceReducer<T=any>{(state: T|undefined,action: any): T}typeUnboxState<RextendsReducer>=RextendsReducer<infer U> ? U : neverdeclarefunctionexample<RextendsReducer,SextendsSelector<UnboxState<R>>>(r: R,s: S) : voidexample((state,action)=>({name: 'Gio Va'}),state=>23)declarefunctionexample2<RextendsReducer,SextendsSelector<UnboxState<R>>>(x: {r: R,s: S}) : voidexample2({r: (state,action)=>({name: 'Gio Va'}),s: state=>23})Expected behavior:
Infer type { name: string } to state in the example2 function as it does correctly in example function.
Actual behavior:
In the example2 function the type inferred to state is any.
Playground Link:
playground
Related Issues:
TypeScript Version: 4.0.5
Search Terms:
infer, object literals, interdependencies
Code
Expected behavior:
Infer type
{ name: string }tostatein theexample2function as it does correctly inexamplefunction.Actual behavior:
In the
example2function the type inferred tostateisany.Playground Link:
playground
Related Issues: