Closed
Description
Problem: in the current state of affairs although convenient to certain audiences the bivariance is a gaping hole in the type system
Solution:
- allow optional but explicit
in
andout
modifiers like in C# for those who wants to take advantage of stricter typechecking - keep bivariant typechecking for anyone who doesn't care:
Array<a> {
map: <b>(map: (value: a) => b) => b[];
)
declare var animals: Array<Animal>;
declare var copyCat: (cat: Cat) => Cat
animals.map(copyCat); // expected not to typecheck, currently allowed no problem
// but if we go
Array<in a> {
map: <b>(map: (value: a) => b) => b[];
)
// then
animals.map(copyCat); // doesn't typecheck anymore as expected
#6102 spinoff