I have an abstract class:
abstract class Connector<T> {
abstract parse(theirData: T[]): OurData[]
}
However, concrete subclasses do not infer the method types from the type parameter:
class APIConnector extends Connector<string> {
// Parameter 'theirData' and return type implicitly has an 'any' type.
parse(theirData) {
...
return connection
}
}
Maybe I am misunderstanding the purpose of TypeScript in this particular instance, but why would the inherited abstract methods not infer the type from the generics? It seems to defeat the point if I have to additionally type-hint the parameter and return types.
I understand that by using generics I am prevented from creating a bad signature for this method, but then if TS already knows what the type is then why would it state it as "implicit any"? Is this an option or something I can toggle in tsconfig?