Skip to content

When relating object literal types to unions, avoid elaborating on Array/ReadonlyArray #25750

Closed

Description

From Adam Rackis (@arackaf):

image

Notice that when comparing an object literal against MutationSubscription | MutationSubscription[], it picked the last branch which is bad.

Kind of like #24776, but here if the type originates from an object literal (or from JSX attributes?), we should avoid matching against Array or ReadonlyArray

Activity

  1. arackaf commented on Jul 18, 2018

    @arackaf

    Thanks for adding this. But it seems that even when running this same code without type annotations, VS Code still freezes up, and plugins stop responding. But what’s interesting is that this problem ONLY happens (both against typings, and with un-typed code) when the run method pictured is an in-line fat arrow.

    If you set it to a variable defined elsewhere, or null, or a method syntax function, it works fine. But Code hates having a fat arrow in that specific position.

  2. DanielRosenwasser commented on Jul 18, 2018

    @DanielRosenwasser
    MemberAuthor

    This was just me noticing you're getting a misguiding error message. 😄

  3. arackaf commented on Jul 18, 2018

    @arackaf

    Daniel Rosenwasser (@DanielRosenwasser) - thanks a ton for adding it. These problems seem to always be more complex than they appear at the surface to me - I was only trying to make sure to give all the details of this.

    So would the problem you describe above also manifest itself (ie VS Code's plugins becoming unresponsive) if the methods I'm calling, buildQuery above, was set to any?

  4. DanielRosenwasser commented on Jul 18, 2018

    @DanielRosenwasser
    MemberAuthor

    Separately from the problem you're seeing, we're just giving a bad error message.

  5. arackaf commented on Jul 18, 2018

    @arackaf

    I don't know - this gets weirder the more things I test. If I take that same syntax, and put it in a separate TS project that does not have my typings, TS accepts that syntax just fine - it doesn't care about the arrow function in that place.

    In my other project with those typings, that basic syntax structure causes massive problems, even if untyped, even if the run method is called runX, for example. It seems those typings are making tsc seriously angry anytime it comes across an arrow function in that position in JSX.

    cc Mohamed Hegazy (@mhegazy)

  6. arackaf commented on Jul 18, 2018

    @arackaf

    Sorry to add so much spam to this issue. It seems even deleting my typings file completely, still causes this JSX to lock VS Code up, with it falsely reporting an error for a good 30 or so seconds. It happens as soon as, and only when I, put the arrow function there.

    I confirmed the typings were gone, and VS Code was in fact reporting these members as any. I'm a bit hesitant to publish this library with TSC hating it so much :)

    Has the cause of this been found yet? Is there anything I can do to help reproduce it?

    /cc Mohamed Hegazy (@mhegazy)

    image

  7. DanielRosenwasser commented on Jul 18, 2018

    @DanielRosenwasser
    MemberAuthor

    It's going to take some time to investigate the problem that you were running into without a minimal repro. This issue really is only about giving a better error message in specific cases (which you can see an example of in #25752).

    I'm a bit hesitant to publish this library with TSC hating it so much :)

    Yeah, I would recommend not publishing with .d.ts in the meantime then if it's going to cause users a lot of pain.

  8. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions