Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rule to warn about properties that are overridden by object spread #184

Closed
ajafff opened this issue Apr 11, 2018 · 0 comments
Closed
Assignees

Comments

@ajafff
Copy link
Member

ajafff commented Apr 11, 2018

let foo = {
    x: 1, // always overridden
    ... {x: 2}
};

let bar = Boolean() ? {prop: 1} : {};
let baz = {
    y: 0,
    prop: 0, // not always overridden, because the property is optional in 'bar'
    ...bar,
};

// this could be an enhancement:
let bas = {
    ...foo, // will be overridden completely by 'x: 3'
    ...bar, // will be overridden completely by '...baz'
    x: 3,
    ...baz, // NOT completely overridden by '...bar', because it doesn't contain 'y'
    ...bar,
    // uncommenting the following line results in an error on '...baz'
    // y: 1,
};

Ref: microsoft/TypeScript#23340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant