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

new rule: no-duplicate-spread-property #185

Merged
merged 10 commits into from
Apr 26, 2018
Merged

Conversation

ajafff
Copy link
Member

@ajafff ajafff commented Apr 12, 2018

Checklist

Overview of change

Adds a rule to detect properties in object literals that are overridden later by a spreaded object.
It also detects spreaded objects that only contain properties that are overridden later.

TBD

  • is there a better name for the rule?
  • how to handle properties that are not optional, but may contain undefined? The compiler doesn't allow assigning optional properties to non-optional ones, but maybe some libraries typings are not correct.

@ajafff
Copy link
Member Author

ajafff commented Apr 26, 2018

Two things to note here:

  • a better name would be no-duplicate-spread-property
  • this rule will never work 100% correct. object spread only copies own properties. properties and methods on the prototype not copied although they part of the type (they cannot be distinguished from own properties)

@ajafff
Copy link
Member Author

ajafff commented Apr 26, 2018

Some more details on the design limitation regarding own properties vs. prototype properties: microsoft/TypeScript#13148 (comment)

TODO: only omit class methods, but include properties with call signatures. See microsoft/TypeScript#13365 for more details

@ajafff ajafff changed the title new rule: no-useless-object-property new rule: no-duplicate-spread-property Apr 26, 2018
@ajafff ajafff merged commit 4e5183b into master Apr 26, 2018
@ajafff ajafff deleted the no-useless-object-property branch April 26, 2018 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant