You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//// Redux types//// import { combineReducers, Reducer } from 'redux';typeReducer<S>=(state: S)=>S;declarefunctioncombineReducers<S>(reducers: {[KinkeyofS]: Reducer<S[K]>}): Reducer<S>;//// Begin example//typeMyState={combined: {foo: number}};declareconstfoo: Reducer<MyState['combined']['foo']>;// When `strictFunctionTypes` is disabled…{// Unexpected type error:// Property 'foo' is missing in type '{}' but required in type '{ foo: number; }'.constmyReducer: Reducer<MyState>=combineReducers({combined: combineReducers({ foo }),});}{// Expected type: Reducer<{ combined: {}; }, AnyAction>// Actual type: Reducer<MyState, AnyAction>constmyReducer=combineReducers({combined: combineReducers({ foo }),});}//// Workaround://{constcombined=combineReducers({ foo });// No type errorconstmyReducer: Reducer<MyState>=combineReducers({
combined,});}{constcombined=combineReducers({ foo });// Correct type inferenceconstmyReducer=combineReducers({
combined,});}
The text was updated successfully, but these errors were encountered:
@ahejlsberg my read on this is that the contextual type inference candidate from the outer call is incorrectly causing {} inference of the inner call. Thoughts?
TypeScript Version: 3.4.1
Search Terms:
Code
The text was updated successfully, but these errors were encountered: