Skip to content

[feature request] consistent index access type for this type #12349

Closed
@HerringtonDarkholme

Description

@HerringtonDarkholme

Sorry it's me again....
it seems this type is resolved too eagerly in parent class.

TypeScript Version: nightly

Code

class A {
  prop: {}
  propCopy: this['prop']
}

class B extends A {
  prop: {field: number}
  propCopy2: this['prop']
}

var b = new B
b.propCopy.field // error here
b.propCopy2.field

Expected behavior:

Code should compile. both propCopy and propCopy2 have the same type.

Actual behavior:

Error on b.propCopy.field, b.propCopy is typed as {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions