3 ms·
Yeah I agree, that's not what I'd consider good variance rules either. I guess my point was more about the reasons behind these weird rules. AFAIK interop with
by inbx0 5y ago
Yeah I agree, that's not what I'd consider good variance rules either.
I guess my point was more about the reasons behind these weird rules. AFAIK interop with existing JavaScript was not the primary reason for doing them this way, if that's any consolation.
FWIW your example wouldn't fly in Flow
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBjGBDAzrsAQQDsBLAW2xgG8BfdLPAgETgHMwBTADwBdPiAEwIkKVMNVRhpYAEbYATgGsAFAEoJUmdoxxiuODE4A6eGxUAiBHDhQLardPr1MOfGADC2Xlz4DhRGSUMJra5JyI6qHaMrr6hiZmluGI9o5gzuikxPwKUNgYnGAAEngACpw+ktIADpUAXIFiMKguUACuxBi8pHpguLztUFAqdQoGxI2luBW8GtUyYxPGdT4AvGDEnEhevOqt6MDAYJTZWTmceQVFAEqc2IJ6MACe06wcC9IA1KuN7weYPQDE6cRp3B5PV54d5gDafMC-TbbMDvfYuI5gADKAAs4O0YIIwABJORFKjwBCcQm8OAIphgbBgcGPYgvN7sMA0hlgDpdHp9XjY7xgBDYHIERnTWYAflQAyGI3CDlQGIA6tjnpzsUVtTAQhgxQByHzkTWrMCPDjyZQM4jPchwBScaWBQkIDUWuCcAikHzwABuRQNvDINX6tPI7Qw2Nl4RWlWM1tUGgxCk6PXCXAUCkdAEIgA https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBjGBDAzrsAQQDsBL...
- ragnese 5y ago> I guess my point was more about the reasons behind these weird rules. AFAIK interop with existing JavaScript was not the primary reason for doing them this way, if that's any consolation. Are you sure? Because there was an essay written by the TypeScript devs when they released whatever version that introduced the strict-function-variance flag explaining why they "couldn't" make it also apply to class methods, and it boiled down to breaking too much existing JavaScript code. That's not proof that the original variance choice was also due to JavaScript compatibility, but I feel like it's a very strong suggestion that it was probably a big motivator. I'm glad that it wouldn't work in Flow. I'm sure it wouldn't work in most/all of the other statically typed compile-to-JavaScript languages. I just hate that none of them won out over TypeScript, so they're basically all irrelevant- Flow included.