Hacker News new | ask | show | jobs
by negativegate 2575 days ago
Interesting, though it does flag the push() as an error if you use "Array<string> | Array<number>" as the argument type.

It almost seems like some sort of co/contravariance issue?

A function that reads from an Array<string | number> should be able to accept either an Array<string> or an Array<number> (or Array<string | number>), but a function that mutates it should only be able to accept Array<string | number>?