microsoft / microsoft/TypeScript
Subclass of a (non-abstract class that uses declaration merging to implement parent abstract member) also has to implement same abstract member
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
subclass inherit abstract concrete method property member complains parent declaration merge merging satisfy implement
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed all the FAQ entries
⏯ Playground Link
💻 Code
interface ParentI {
foo(): void
}
abstract class Parent {
abstract foo(): void
}
// Middle implements Parent via declaration merge
class Middle extends Parent {}
interface Middle extends ParentI {}
class Child extends Middle {} // doesn't work
// Middle implements Parent directly
class Middle2 extends Parent {
foo() {}
}
class Child2 extends Middle2 {} // works
🙁 Actual behavior
Typescript complains that Child must implement an foo, even though Middle has already implemented foo via declaration merging.
🙂 Expected behavior
I would expect Child to pass type-checking, just as Child2 does. Seeing as how Middle (a concrete class) is type-safe and Child extends Middle with no further modification, this feels very surprising.
Additional information about the issue
No response
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 with the provided TypeScript Playground reproduction and compare the declaration-merging example with the directly implemented Middle2 case. Trace the compiler's handling of abstract members across merged class and interface declarations, then add a regression test showing that Child type-checks without implementing foo itself.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100