Closed
Description
TypeScript Version: 2.9
Search Terms: excess key in returned object in function
Code
interface ITestFunctionReturns {
key1: number,
key2: string,
}
type ITestFunction = () => ITestFunctionReturns
const testFunction: ITestFunction = () => ({
asd: true,
key1: 123,
key2: 'str',
})
Expected behavior: typescript will report about extra key in the object
Actual behavior: I must point the interface in yet another place, without this typescript does not report an error
interface ITestFunctionReturns {
key1: number,
key2: string,
}
type ITestFunction = () => ITestFunctionReturns
const testFunction: ITestFunction = (): ITestFunctionReturns => ({
asd: true,
key1: 123,
key2: 'str',
})