TypeScript中的协变与逆变

156 阅读1分钟

Reference :协变与逆变

什么协变和逆变

What are covariance and contravariance? (中文版)

为什么TypeScript中的函数是双向协变

Why are function parameters bivariant?

TypeScript函数参数类型默认是双向协变,可以通过strictFunctionTypes标志将函数参数设置成逆变的

Strict function types 的作用