40 lines
713 B
TypeScript
40 lines
713 B
TypeScript
|
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;
|