Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error using intersection type for object rest destructuring #12520

Copy link
Copy link
@billti

Description

@billti
Issue body actions

This is using the latest release-2.1 branch. I'm unclear why types B & C would behave differently below when it comes to object rest members, so I am assuming this is a bug. (ping @sandersn & @mhegazy ).

interface A {
    name: string;
    age: number;
}

interface B extends A {
    address: string;
}

type C = A & {address: string};

// Both v1 & v2 appear to have the same members...
var v1: B;
var v2: C;

// ... and assignment in either direction is fine
v1 = v2; // OK
v2 = v1; // OK

// let {name, ...x2} = v1;  // This line is valid (when uncommented)
let {name, ...x3} = v2;  // This line gives the error: Rest types may only be created from object types.
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.