Skip to content

Abstract properties overwritten in sub class are undefined within parent constructor #15247

Closed
@PMXScott

Description

@PMXScott

TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)

Code

abstract class A {
	public abstract names:string;
	public constructor() {
		console.log(this.names);
	}
	public speak() {
		console.log(this.names);
	}
}

class B extends A {
	public names:string= "scott";
}

new B().speak();

Expected behavior:

Output to be

scott
scott

Actual behavior:

undefined
scott

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions