1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
//// [varianceAnnotationValidation.ts]
// Repro from #49607
// Variance annotation error expected
interface Controller<out T> {
createAnimal: () => T;
run: (animal: T) => void;
}
interface Animal {
run(): void;
};
class Dog implements Animal {
run() {};
bark() {};
}
interface AnimalContainer<T> {
controller: Controller<T>;
}
declare let ca: AnimalContainer<Animal>;
declare let cd: AnimalContainer<Dog>;
ca = cd; // Ok
cd = ca; // Error
//// [varianceAnnotationValidation.js]
"use strict";
// Repro from #49607
;
var Dog = /** @class */ (function () {
function Dog() {
}
Dog.prototype.run = function () { };
;
Dog.prototype.bark = function () { };
;
return Dog;
}());
ca = cd; // Ok
cd = ca; // Error
//// [varianceAnnotationValidation.d.ts]
interface Controller<out T> {
createAnimal: () => T;
run: (animal: T) => void;
}
interface Animal {
run(): void;
}
declare class Dog implements Animal {
run(): void;
bark(): void;
}
interface AnimalContainer<T> {
controller: Controller<T>;
}
declare let ca: AnimalContainer<Animal>;
declare let cd: AnimalContainer<Dog>;
|