Skip to content

Fix excess property check in union and intersection types - #5344

Merged
Anders Hejlsberg (ahejlsberg) merged 2 commits into
masterfrom
excessPropertiesWithUnion
Oct 20, 2015
Merged

Anders Hejlsberg (ahejlsberg) merged 2 commits into
masterfrom
excessPropertiesWithUnion

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Fixes #5237.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have phrased that using four words

@DanielRosenwasser

Copy link
Copy Markdown
Member

LGTM

@mhegazy

Copy link
Copy Markdown
Contributor

👍

@ahejlsberg

Copy link
Copy Markdown
Member Author

The PR modifies the rules for excess properties as follows:

A source type S is considered to have excess properties with respect to a target type T if

  • S is a fresh object literal type,
  • T is an object-like type, and
  • S has one or more properties that aren't expected in T.

A type T is said to be object-like if

  • T is an object type, or
  • T a union or intersection type containing at least one-object like type.

A property P is said to be expected in a type T if one of the following is true:

  • T is an object type and
    • T has a property with the same name as P,
    • T has a string or numeric index signature,
    • T has no properties, or
    • T is the global type 'Object'.
  • T is a union or intersection type and P is expected in at least one object-like constituent type of T.

Anders Hejlsberg (ahejlsberg) added a commit that referenced this pull request Oct 20, 2015
Fix excess property check in union and intersection types
@mhegazy
Mohamed Hegazy (mhegazy) deleted the excessPropertiesWithUnion branch October 20, 2015 21:17
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants