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

Should leading ampersands (&) be allowed in intersection types? #17916

Closed
Ailrun opened this issue Aug 18, 2017 · 6 comments
Closed

Should leading ampersands (&) be allowed in intersection types? #17916

Ailrun opened this issue Aug 18, 2017 · 6 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@Ailrun
Copy link

Ailrun commented Aug 18, 2017

TypeScript Version: 2.4.2 / playground (2.3.?)

Code

let x: (& number & string);

Expected behavior:
Emits error, since language spec said,

IntersectionType: IntersectionOrPrimaryType & PrimaryType

in the subsection 3.8.7

Actual behavior:
Doesn't emit error and uses it as number & string.

@Ailrun Ailrun changed the title Is this a bug? Wierd intersection type / Is this a bug? Aug 18, 2017
@Ailrun Ailrun changed the title Wierd intersection type / Is this a bug? Weird intersection type / Is this a bug? Aug 18, 2017
@yortus
Copy link
Contributor

yortus commented Aug 19, 2017

@Ailrun it is by design. See #12386. The spec might need updating though.

@Ailrun
Copy link
Author

Ailrun commented Aug 19, 2017

@yortus Why don't anyone try to fix the spec? Isn't specification of language the most important document?

@yortus
Copy link
Contributor

yortus commented Aug 21, 2017

The spec hasn't been updated since January 2016, so it's likely that a bunch of stuff is missing or outdated. I'm not sure why this is; my guess would be time pressure on the team, and the fact that they don't directly take PRs for the spec. Perhaps a team member can chime in.

@ikatyang
Copy link
Contributor

See #17215 (comment).

@Ailrun
Copy link
Author

Ailrun commented Aug 21, 2017

@yortus Alright... thank you for your answer!
@ikatyang Thank you for information!

@DanielRosenwasser DanielRosenwasser added the Working as Intended The behavior described is the intended behavior; this is not a bug label Aug 22, 2017
@DanielRosenwasser DanielRosenwasser changed the title Weird intersection type / Is this a bug? Should leading ampersands (&) be allowed in intersection types? Aug 22, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 6, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 6, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

5 participants