Skip to content

Better error message for invalid assignment of tuples to arrays #830

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

Closed
yuit opened this issue Oct 6, 2014 · 2 comments
Closed

Better error message for invalid assignment of tuples to arrays #830

yuit opened this issue Oct 6, 2014 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@yuit
Copy link
Contributor

yuit commented Oct 6, 2014

As suggested in PR #822, error messages for Tuple type is unclear in explaining why certain tuple can be assigned to array. It will be helpful for users to get messages which provide more directed information.

@yuit yuit added the Bug A bug in TypeScript label Oct 6, 2014
@DanielRosenwasser DanielRosenwasser changed the title Report more directed, useful information in error message Better error message for invalid assignment of tuples to arrays Oct 6, 2014
@mhegazy mhegazy modified the milestones: Community, TypeScript 1.4 Nov 3, 2014
@mhegazy mhegazy unassigned yuit Nov 3, 2014
@mhegazy mhegazy added the Help Wanted You can do this label Feb 20, 2016
@begincalendar
Copy link
Contributor

Could we please get some information on what exactly is needed with this issue?

error TS2322: Type '[number, string]' is not assignable to type 'number[]' seems adequate to me, but I also see that:

  Types of property 'pop' are incompatible.
    Type '() => string | number' is not assignable to type '() => number'.
      Type 'string | number' is not assignable to type 'number'.
        Type 'string' is not assignable to type 'number'.

...is not really helpful.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 26, 2017

Looking at this again, i agree the error message we have today is good enough. closing as such.

The additional elaboration is the standard structural type comparison elaboration you would get elsewhere.

@mhegazy mhegazy closed this as completed Oct 26, 2017
@mhegazy mhegazy added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Bug A bug in TypeScript Help Wanted You can do this labels Oct 26, 2017
@mhegazy mhegazy removed this from the Community milestone Oct 26, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 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

4 participants