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

Avoid elaborating missing properties on common container types #35300

Closed
DanielRosenwasser opened this issue Nov 22, 2019 · 6 comments
Closed
Assignees
Labels
Domain: Error Messages The issue relates to error messaging Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@DanielRosenwasser
Copy link
Member

As a separate change, it might be nice to special case the message Foo is not assignable to Promise<Foo> to say something about adding await, rather than listing missing properties.

Originally posted by @amcasey in #35278

@DanielRosenwasser DanielRosenwasser changed the title Avoid elaborating missing properties when common container types have no overlap Avoid elaborating missing properties on common container types Nov 22, 2019
@DanielRosenwasser
Copy link
Member Author

  • Array
  • ReadonlyArray
  • Promise
  • Set
  • Map
  • WeakSet
  • WeakMap
  • Typed Arrays

@DanielRosenwasser DanielRosenwasser added Domain: Error Messages The issue relates to error messaging Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this Experience Enhancement Noncontroversial enhancements labels Nov 22, 2019
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.8.1 milestone Nov 22, 2019
@fatcerberus
Copy link

special case the message Foo is not assignable to Promise<Foo>

Isn't that backwards? It should be the other way around because:

declare let foo: Foo;
declare let fooPromise: Promise<Foo>;
fooPromise = foo;

adding an await wouldn't actually help you in the case above. It would if the assignment were the other way around.

@Kingwl
Copy link
Contributor

Kingwl commented Nov 25, 2019

Any common error message? Such as maybe you should wrap xx into yy

@weswigham
Copy link
Member

Do you need an 'X' of 'Y'? ex, Do you need an 'Array' of 'number'? or Do you need an 'IteratorResult' of '{x: number, y: number}'? maybe? Eh, that's maybe not great when X has multiple generics, as it's ambiguous to which you're referring.

@weswigham
Copy link
Member

I do think promise is a bit more special than the rest of these, however - passing a Promise.resolve(x) rather than just x is common given promise-based API shapes. Wrapping a single value into a collection, however, I'd find much more suspect.

@RyanCavanaugh
Copy link
Member

This works as expected now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Error Messages The issue relates to error messaging Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

6 participants