Abstract class type argument inference
See original GitHub issueIt 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.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Infer arguments for abstract class in typescript - Stack Overflow
It is possible to infer parameters of abstract class. You just need to add abstract keyword before new . See example:
Read more >Type inference of class type parameter in abstract method-kotlin
How to create a class with a method that returns a subtype with a type parameter in Kotlin? ... Can you inherit from...
Read more >Chapter 3. Type system - Ceylon
Each class declaration defines a type. However, not all types are classes. It is often advantageous to write generic code that abstracts the...
Read more >Generics: in, out, where | Kotlin Documentation
The set of all possible types that can be substituted for a given type parameter may be restricted by generic constraints. Upper bounds....
Read more >Documentation - Classes - TypeScript
Constructors can't have type parameters - these belong on the outer class declaration, ... TypeScript has some special inference rules for accessors:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aluanhaddad I suggested it applied to abstract, mostly because abstract implies there will be at least another declaration. But after thinking about it, I cannot see why it’s not applicable to normal classes as well.
I hope it apply to normal class also. see https://github.com/ant-design/ant-design/issues/4324