Skip to content

Object spread allows unknown properties as function return values #17422

Closed
@thasner

Description

@thasner

TypeScript Version: 2.4.2

Code

interface IState {
    foo: number;
}
export const fun: (state: IState) => IState = (state) => {
    return { ...state, bar: 2 };
};

Expected behavior:

Object literal may only specify known properties, and 'bar' does not exist in type 'IState'.

Actual behavior:

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions