TypeScript/tests/baselines/reference/interfaceClassMerging.js
2015-12-08 17:51:10 -08:00

76 lines
1.6 KiB
TypeScript

//// [interfaceClassMerging.ts]
interface Foo {
method(a: number): string;
optionalMethod?(a: number): string;
property: string;
optionalProperty?: string;
}
class Foo {
additionalProperty: string;
additionalMethod(a: number): string {
return this.method(0);
}
}
class Bar extends Foo {
method(a: number) {
return this.optionalProperty;
}
}
var bar = new Bar();
bar.method(0);
bar.optionalMethod(1);
bar.property;
bar.optionalProperty;
bar.additionalProperty;
bar.additionalMethod(2);
var obj: {
method(a: number): string;
property: string;
additionalProperty: string;
additionalMethod(a: number): string;
};
bar = obj;
obj = bar;
//// [interfaceClassMerging.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; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Foo = (function () {
function Foo() {
}
Foo.prototype.additionalMethod = function (a) {
return this.method(0);
};
return Foo;
}());
var Bar = (function (_super) {
__extends(Bar, _super);
function Bar() {
_super.apply(this, arguments);
}
Bar.prototype.method = function (a) {
return this.optionalProperty;
};
return Bar;
}(Foo));
var bar = new Bar();
bar.method(0);
bar.optionalMethod(1);
bar.property;
bar.optionalProperty;
bar.additionalProperty;
bar.additionalMethod(2);
var obj;
bar = obj;
obj = bar;