Open
Description
TypeScript Version: 2.8.0-insiders.20180320
Search Terms: mapped type inference display typetostring
Code
Via https://stackoverflow.com/questions/50181650/type-inference-lost-inner-level-types-in-typescript
interface IAction {
type: string;
}
type Reducer<S> = (state: S, action: IAction) => S
function combineReducers<S>(reducers: { [K in keyof S]: Reducer<S[K]> }): Reducer<S> {
const dummy = {} as S;
return () => dummy;
}
const test_inner = (test: string, action: IAction) => {
return 'dummy';
}
const test = combineReducers({
test_inner
});
const test_outer = combineReducers({
test
});
// '{test: { test_inner: any } }'
type FinalType = ReturnType<typeof test_outer>;
var k: FinalType;
k.test.test_inner // 'string'
Expected behavior: FinalType
's hover type should be { test: { test_inner: string } }
Actual behavior: Shows as { test: { test_inner: any } }
Playground Link: Link