Closed
Description
TypeScript Version: 3.3.0-dev.20181121
Search Terms: function types, return types, inconsistent
Code
const test = { 1: '', 2: '', 3: '' };
type keys = { [key in keyof typeof test]: string };
type StateFunction<TState> = () => TState;
const a: StateFunction<keys> = () => ({ ...test, 4: '' }); //Does not error
const b = (): keys => ({ ...test, 4: '' }); //Errors properly
Expected behavior:
const a: StateFunction<keys> = () => ({ ...test, 4: '' });
Should error
Actual behavior:
const a: StateFunction<keys> = () => ({ ...test, 4: '' });
Does not error