Skip to content

Overload signature choice failure (regression) #26813

Closed

Description

TypeScript Version: 3.1.0-dev.20180831

Search Terms:

Code

https://github.com/falsandtru/spica/blob/v0.0.197/src/monad/maybe.test.ts#L102

Expected behavior:

pass

Actual behavior:

TypeScript error: src/monad/maybe.test.ts(102,9): Error TS2684: The 'this' context of type 'Maybe<(a: number) => number>' is not assignable to method's 'this' of type 'Maybe<(a: (a: number) => number, b: {}, c: {}, d: {}, e: {}) => number>'.
  Type '(a: number) => number' is not assignable to type '(a: (a: number) => number, b: {}, c: {}, d: {}, e: {}) => number'.
    Types of parameters 'a' and 'a' are incompatible.
      Type '(a: number) => number' is not assignable to type 'number'.

Playground Link:

Related Issues:

Activity

  1. falsandtru commented on Aug 31, 2018

    @falsandtru
    ContributorAuthor

    Looks like this bug is based on an explicit type inference bug of function arguments and type arguments:

    - Maybe<(a: number) => number>
    + Maybe<(a: (a: number) => number, b: {}, c: {}, d: {}, e: {}) => number>

    (a: number) => number can't appear at the place of function argument type.

    Here is the definition at there:

      public ap<a, z>(this: Maybe<(a: a) => z>, a: Maybe<a>): Maybe<z>
      public ap<a, b, z>(this: Maybe<(a: a, b: b) => z>, a: Maybe<a>): Maybe<(b: b) => z>
      public ap<a, b, c, z>(this: Maybe<(a: a, b: b, c: c) => z>, a: Maybe<a>): Maybe<(b: b, c: c) => z>
      public ap<a, b, c, d, z>(this: Maybe<(a: a, b: b, c: c, d: d) => z>, a: Maybe<a>): Maybe<(b: b, c: c, d: d) => z>
      public ap<a, b, c, d, e, z>(this: Maybe<(a: a, b: b, c: c, d: d, e: e) => z>, a: Maybe<a>): Maybe<(b: b, c: c, d: d, e: e) => z>
  2. ahejlsberg commented on Sep 1, 2018

    @ahejlsberg
    Member

    Fixed by #26820, no longer reproduces in master branch.

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

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions