develwoutacause’s avatardevelwoutacause’s Twitter Archive—№ 727

  1. 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
    1. …in reply to @develwoutacause
      I would expect it to fail because doing: const instance: Parent = new Child(); instance.run(0); // Child expects Is putting a number into a function that expects only a string. I'm very surprised to find that this compiles successfully.