Skip to content

No error when initializing a class field defined as a read-only getter in base class #34585

Description

@trusktr

TypeScript Version: 3.6.4

Search Terms:

"Related Issues" feature of GitHub uses the title as search terms.

Code

class Base {
  get foo() {
    return 5
  }
}

class Child extends Base {
  foo = 10
}

new Child // runtime error!

Expected behavior:

Type error during compile

Actual behavior:

No error until runtime.

Playground Link:

playground

Related Issues:

Might be duplicate of #13347, but not sure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions