Skip to content

Function interface doesn't type check return value for extra keys #12632

Closed
@carloslfu

Description

@carloslfu

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

See next code, also in This playground.

Code

interface F {
    (p: {a:number}): {a: string}
}

// there are no type check for extra keys
// but F interface has return type
let g: F = ({a}) => ({
    a: '5',
    b: '',
})

// we need to do that!, but F interface also has return type
let f: F = ({a}): {a: string} => ({
    a: '5',
    b: '',
})

Expected behavior:

'g' function should be detected as an error, because return type of interface F doesn't have key 'b', just haves 'a' key

Actual behavior:

'g' function doesn't display any error

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions