Incorrect function parameter not detected · Issue #13248 · microsoft/TypeScript (original) (raw)
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(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.