Skip to content

Intersection type of two array types does not widen in callback #11961

Closed
@NoelAbrahams

Description

@NoelAbrahams

Hi, Guys,

Something a bit strange here:

TypeScript Version: 2.0.6

Code

    type foo1 = { id: number}[];
    type foo2 = { id: number, value: string }[];
    type foo3 = foo1 & foo2;

    var x: foo3;
    x[0].value; // okay
    x.forEach(item => {

        // Error: Property 'value' does not exist on type '{ id: number; }'.
        item.value; 
    });

Expected behavior:

No error when property value is referenced in the body of the forEach.

Actual behavior:

The compiler reports an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions