Skip to content

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

Closed

Description

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.

Activity

  1. changed the title [-]Is this a bug?[/-] [+]Wierd intersection type / Is this a bug?[/+] on Aug 18, 2017
  2. changed the title [-]Wierd intersection type / Is this a bug?[/-] [+]Weird intersection type / Is this a bug?[/+] on Aug 18, 2017
  3. yortus commented on Aug 19, 2017

    @yortus
    Contributor

    Junyoung/"Clare" Jang (@Ailrun) it is by design. See #12386. The spec might need updating though.

  4. Ailrun commented on Aug 19, 2017

    @Ailrun
    Author

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

  5. yortus commented on Aug 21, 2017

    @yortus
    Contributor

    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.

  6. ikatyang commented on Aug 21, 2017

    @ikatyang
    Contributor
  7. Ailrun commented on Aug 21, 2017

    @Ailrun
    Author

    Troy Gerwien (@yortus) Alright... thank you for your answer!
    Ika (@ikatyang) Thank you for information!

  8. changed the title [-]Weird intersection type / Is this a bug?[/-] [+]Should leading ampersands (&) be allowed in intersection types?[/+] on Aug 22, 2017
  9. mhegazy commented on Sep 6, 2017

    @mhegazy
    Contributor

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

  10. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions