microsoft / microsoft/TypeScript
Abstract class type argument inference
Open
Nobody has claimed this yet.
Committed
Domain: JavaScript
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
It would be good if TypeScript can infer the type of an extended class of an generic abstract class:
abstract class A<T> {
abstract a: T;
get(): T {
return '' as any;
}
}
class B extends A {
a: 'helloworld';
}
const b = new B():
b.get(); // string
In a similar fashion, it does inference elsewhere.
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 minimal abstract-class example from the issue and inspect TypeScript's type-checker inference path. Determine how the extended class's property type should supply the abstract base type argument, then add coverage for the shown case and related inference behavior. Done means B.get() is typed as the inferred property type rather than an unresolved or broad type.
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
- 25/100