Content-Length: 280349 | pFad | https://github.com/microsoft/TypeScript/issues/13248

70 Incorrect function parameter not detected · Issue #13248 · microsoft/TypeScript · GitHub
Skip to content

Incorrect function parameter not detected #13248

Closed
@TeamworkGuy2

Description

@TeamworkGuy2

TypeScript Version: (maybe 2.1.x - typescriptlang.org playground version as of 2017-1-2)

Code
typescriptlang.org playground

[1, 2, 3].map(mapper); // fine???
[1, 2, 3].map((obj, idx) => mapper(obj, idx)); // <= error

type Tag = number & { _tagBrand: any; };

function mapper<E>(obj: E, type: Tag) {
    return obj;
}

Expected behavior:
The first map() call on line 1 should throw the same compile error as the second call, since the second parameter of the mapper function does not match the second parameter of the function expected by Array.map()

Actual behavior:
No compile error on the first map() call when it should.

Found while working on nominal types based on basarat's git book 'Nominal Typings' section.

Reproduced in VS 2015 update 3 TypeScript 2.1.4 and the typescriptlang.org playground.

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









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/microsoft/TypeScript/issues/13248

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy