3 ms·
TypeScript allows this too, unfortunately. https://www.typescriptlang.org/play?#code/MYewdgziA2CmB00QHMAUBtARARkwGgAJMAmfIgZkwF14BbAQwAdVH6AnCWASTABcBKfkA https
by jjnoakes 3y ago
TypeScript allows this too, unfortunately. https://www.typescriptlang.org/play?#code/MYewdgziA2CmB00QHMAUBtARARkwGgAJMAmfIgZkwF14BbAQwAdVH6AnCWASTABcBKfkA https://www.typescriptlang.org/play?#code/MYewdgziA2CmB00QHM...
- wizofaus 3y agoAh, that semi-answers my question - but why? Surely the signature of parseInt doesn't match what map requires for its function parameter?
- jjnoakes 3y agoI agree that it would be nice if it flagged this kind of thing. But TypeScript disagrees. https://github.com/microsoft/TypeScript/wiki/FAQ#why-are-functions-with-fewer-parameters-assignable-to-functions-that-take-more-parameters https://github.com/microsoft/TypeScript/wiki/FAQ#why-are-fun...
- wizofaus 3y agoInteresting but certainly disagree with the reasoning, that somehow having to explicitly discard the unused parameters would be "burdensome", certainly compared to the need to explicitly declare types for complex arbitrary data structures. If you're not even prepared to write, say, array.map((n, _, _) => parseInt(n)) then why bother using a strictly type checked language...
- jjnoakes 3y agoAgreed on all counts.