Inconsistent function return type vs return type #28634
Labels
Bug
A bug in TypeScript
Duplicate
An existing issue was already created
Fix Available
A PR has been opened for this issue
Milestone
TypeScript Version: 3.3.0-dev.20181121
Search Terms: function types, return types, inconsistent
Code
Expected behavior:
const a: StateFunction<keys> = () => ({ ...test, 4: '' });
Should errorActual behavior:
const a: StateFunction<keys> = () => ({ ...test, 4: '' });
Does not errorPlayground Link: http://www.typescriptlang.org/play/#src=const%20test%20%3D%20%7B%201%3A%20''%2C%202%3A%20''%2C%203%3A%20''%20%7D%3B%0D%0A%0D%0Atype%20keys%20%3D%20%7B%20%5Bkey%20in%20keyof%20typeof%20test%5D%3A%20string%20%7D%3B%0D%0Atype%20StateFunction%3CTState%3E%20%3D%20()%20%3D%3E%20TState%3B%0D%0A%0D%0Aconst%20a%3A%20StateFunction%3Ckeys%3E%20%3D%20()%20%3D%3E%20(%7B%20...test%2C%204%3A%20''%20%7D)%3B%0D%0A%0D%0Aconst%20b%20%3D%20()%3A%20keys%20%3D%3E%20(%7B%20...test%2C%204%3A%20''%20%7D)%3B
The text was updated successfully, but these errors were encountered: