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

empty object should be an identity type relative to the intersection operation #14762

Closed
zpdDG4gta8XKpMCd opened this issue Mar 21, 2017 · 5 comments
Assignees
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@zpdDG4gta8XKpMCd
Copy link

type T = {} & { value: 1 } // expected to be { value: 1 }, actual { value: 1 } & {}
@RyanCavanaugh
Copy link
Member

What's the observable effect of this? Other than the string representation looking weirdish

@zpdDG4gta8XKpMCd
Copy link
Author

zpdDG4gta8XKpMCd commented Mar 21, 2017 via email

@RyanCavanaugh RyanCavanaugh added In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels Mar 21, 2017
@RyanCavanaugh
Copy link
Member

Seems like we should just special case it out of & in typeToString

@zpdDG4gta8XKpMCd
Copy link
Author

just checked the latest nightly version, still see it:
image

@RyanCavanaugh RyanCavanaugh added Committed The team has roadmapped this issue and removed In Discussion Not yet reached consensus labels Apr 3, 2017
@RyanCavanaugh
Copy link
Member

We can remove this during createIntersectionType as long as at least one of the other constituents is objectlike (thus there would be no effects of having it in the intersection). Types like string & { } are still distinct from string so will need to keep { } in the intersection

@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Apr 5, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants