Skip to content

Commit b1c9386

Browse files
authored
Covariance and contravariance explanation is wrong (#3272)
1 parent 078f7ee commit b1c9386

File tree

1 file changed

+1
-1
lines changed
  • packages/documentation/copy/en/handbook-v2/Type Manipulation

1 file changed

+1
-1
lines changed

packages/documentation/copy/en/handbook-v2/Type Manipulation/Generics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ interface Consumer<T> {
449449
consume: (arg: T) => void;
450450
}
451451
```
452-
Then we can use a `Consumer<Animal>` where a `Consumer<Cat>` is expected, because any function that is capable of accepting a `Cat` must also be capable of accepting an `Animal`.
452+
Then we can use a `Consumer<Animal>` where a `Consumer<Cat>` is expected, because any function that is capable of accepting an `Animal` must also be capable of accepting a `Cat`.
453453
This relationship is called *contravariance*: the relationship from `Consumer<T>` to `Consumer<U>` is the same as the relationship from `U` to `T`.
454454
Note the reversal of direction as compared to covariance! This is why contravariance "cancels itself out" but covariance doesn't.
455455

0 commit comments

Comments
 (0)