镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@yuit

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.

Activity

  1. changed the title [-]Report more directed, useful information in error message[/-] [+]Better error message for invalid assignment of tuples to arrays[/+] on Oct 6, 2014
  2. modified the milestones: , TypeScript 1.4 on Nov 3, 2014
  3. begincalendar commented on Oct 26, 2017

    @begincalendar
    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.

  4. mhegazy commented on Oct 26, 2017

    @mhegazy
    Contributor

    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.

  5. added
    Working as IntendedThe behavior described is the intended behavior; this is not a bug
    and removed
    BugA bug in TypeScript
    on Oct 26, 2017
  6. removed this from the milestone on Oct 26, 2017
  7. locked and limited conversation to collaborators on Jun 18, 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