TypeScript/tests/cases/compiler/abstractPropertyInConstructor.ts
2017-10-16 09:43:49 -07:00

38 lines
808 B
TypeScript

abstract class AbstractClass {
constructor(str: string, other: AbstractClass) {
this.method(parseInt(str));
let val = this.prop.toLowerCase();
if (!str) {
this.prop = "Hello World";
}
this.cb(str);
// OK, reference is inside function
const innerFunction = () => {
return this.prop;
}
// OK, references are to another instance
other.cb(other.prop);
}
abstract prop: string;
abstract cb: (s: string) => void;
abstract method(num: number): void;
method2() {
this.prop = this.prop + "!";
}
}
class User {
constructor(a: AbstractClass) {
a.prop;
a.cb("hi");
a.method(12);
a.method2();
}
}