Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is bivariant parameter? ~ TypeScript

The TypeScript's docs comes with Compiler Options, where the --strictFunctionTypes is defined with its description. Unfortunately, can't get what is bivariant parameter. I tried to understand https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant as well.

like image 943
Daniel Danielecki Avatar asked Aug 14 '19 17:08

Daniel Danielecki


1 Answers

A "bivariant" parameter is one that is both covariant and contravariant.

The TypeScript 2.6 release notes describe the --strictFunctionTypes compiler option well, since that's the first release that supported it.

Under --strictFunctionTypes function type parameter positions are checked contravariantly instead of bivariantly. For some background on what variance means for function types check out What are covariance and contravariance?.

This article linked in that quote describes the difference between covariance and contravariance: https://www.stephanboyer.com/post/132/what-are-covariance-and-contravariance

like image 186
Austin Fahsl Avatar answered Oct 23 '22 07:10

Austin Fahsl