-
Discovered today that #TypeScript apparently doesn't type check contravariance (if I'm using that term correctly)?
interface Parent { run(arg: string | number): void; } interface Child extends Parent { // No error? run(arg: string): void; }bit.ly/2UwJHRB -
I would expect it to fail because doing:
const instance: Parent = new Child(); instance.run(0); // Child expectsIs putting anumberinto a function that expects only astring. I'm very surprised to find that this compiles successfully.
develwoutacause’s Twitter Archive—№ 727