studye / typescript

타입스크립트는 자바스크립트랑 다른 언어인가요?
7 stars 0 forks source link

[typescript - 2.4] Strict contravariance for callback parameters #50

Open sculove opened 7 years ago

sculove commented 7 years ago
interface Mappable<T> {
    map<U>(f: (x: T) => U): Mappable<U>;
}

declare let a: Mappable<number>;
declare let b: Mappable<string | number>;

a = b; // should fail, now does.
b = a; // should succeed, continues to do so.