microsoft / microsoft/TypeScript
Proposal: allow ambient property declarations to override accessors as well
Open
Nobody has claimed this yet.
In Discussion
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the class examples in the issue and compare the current diagnostic with the expected behavior. The change is complete when the ambient declaration can override the inherited accessor without an error, C.p has the declared type, and D can still declare the accessor shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100