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

Warn on unused property in object literal with spread #23340

Copy link
Copy link
@ghost

Description

TypeScript Version: 2.9.0-dev.20180411

Search Terms: object spread unused property

Code

interface Point { x: number; y: number; }
function withX(p: Point, x: number): Point {
    if (something) {
        return { x, x: p.x, y: p.y }; // Error
    } else {
        return { x, ...p }; // No error
    }
}

Expected behavior:

Error at { x, ...p }: The first x is dead because ...p has its own non-optional x.

Actual behavior:

No error at { x, ...p }.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript

    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.