Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add in, out modifiers to allow being specific of expected contrvariant/covariant type parameters #8137

Closed
zpdDG4gta8XKpMCd opened this issue Apr 17, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@zpdDG4gta8XKpMCd
Copy link

zpdDG4gta8XKpMCd commented Apr 17, 2016

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 and out 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

@RyanCavanaugh
Copy link
Member

Duplicate of #1394

@mhegazy mhegazy closed this as completed Apr 19, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Apr 19, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants