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

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

Closed
DanielRosenwasser opened this issue Jul 18, 2018 · 7 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

From @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

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging labels Jul 18, 2018
@DanielRosenwasser DanielRosenwasser self-assigned this Jul 18, 2018
@arackaf
Copy link

arackaf commented Jul 18, 2018

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.

@DanielRosenwasser
Copy link
Member Author

DanielRosenwasser commented Jul 18, 2018

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

@arackaf
Copy link

arackaf commented Jul 18, 2018

@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?

@DanielRosenwasser
Copy link
Member Author

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

@arackaf
Copy link

arackaf commented Jul 18, 2018

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 @mhegazy

@arackaf
Copy link

arackaf commented Jul 18, 2018

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 @mhegazy

image

@DanielRosenwasser
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants