Skip to content

Proposal: allow ambient property declarations to override accessors as well #40220

@sandersn

Description

@sandersn

Currently, this pattern gives an error, but arguably shouldn't:

class B {
  get p() { return B.s } // inferred p: {}
  static get s() { return {} }
}
class C extends B {
  declare readonly p: { x: 1 }
}

Expected behavior:

No error, and C.p: { x: 1 } (but is still an accessor for emit and checking purposes). That is, this should be legal:

class D extends C {
  get p() { return { x: 1 } as const }
}

Actual behavior:

Error, and C.p is a property, not an accessor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions