TypeScript/tests/baselines/reference/genericCallbacksAndClassHierarchy.js
2015-05-01 10:49:54 -07:00

69 lines
1.7 KiB
TypeScript

//// [genericCallbacksAndClassHierarchy.ts]
module M {
export interface I<T> {
subscribe(callback: (newValue: T) => void ): any;
}
export class C1<T> {
public value: I<T>;
}
export class A<T> {
public dummy: any;
}
export class B<T> extends C1<A<T>> { }
export class D<T> {
_subscribe(viewModel: B<T>): void {
var f = (newValue: A<T>) => { };
var v: I<A<T>> = viewModel.value;
// both of these should work
v.subscribe(f);
v.subscribe((newValue: A<T>) => { });
}
}
}
//// [genericCallbacksAndClassHierarchy.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var M;
(function (M) {
var C1 = (function () {
function C1() {
}
return C1;
})();
M.C1 = C1;
var A = (function () {
function A() {
}
return A;
})();
M.A = A;
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
})(C1);
M.B = B;
var D = (function () {
function D() {
}
D.prototype._subscribe = function (viewModel) {
var f = function (newValue) { };
var v = viewModel.value;
// both of these should work
v.subscribe(f);
v.subscribe(function (newValue) { });
};
return D;
})();
M.D = D;
})(M || (M = {}));