Skip to content

Spread on object breaks assignability check #15029

Closed
@wclr

Description

@wclr

Didn't find an issue on this.

TypeScript Version: 2.2.2

Code

type A = {
  a: string,
  b: string
}

let a: A = {
  a: '1', b: '2', c: 3,
  ...{ x: 1 } // no error
} 

Expected behavior:
I would expect TS Error like in this case

type A = {
  a: string,
  b: string
}

let a: A = {
  a: '1', b: '2', c: 3 // error: Object literal may only specify known properties, and 'c' does not exist in type 'A'
} 

Actual behavior:
No error

Activity

RyanCavanaugh

RyanCavanaugh commented on Apr 5, 2017

@RyanCavanaugh
Member

See #12745

wclr

wclr commented on Apr 5, 2017

@wclr
Author

@RyanCavanaugh what spread has to do with unions?

RyanCavanaugh

RyanCavanaugh commented on Apr 5, 2017

@RyanCavanaugh
Member

Oops, #13878

locked and limited conversation to collaborators on Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sandersn@wclr@RyanCavanaugh

        Issue actions

          Spread on object breaks assignability check · Issue #15029 · microsoft/TypeScript