I'm trying to figure out how to provide a type definition that corresponds to "all classes that implement some abstract class." Take the following code example:
abstract class AbstractFoo {
abstract foo()
}
class Concrete1 extends AbstractFoo {
foo() { ... }
}
class Concrete1 extends AbstractFoo {
foo() { ... }
}
Now, I'm trying to create a map that goes from string to one of the concrete classes. Note that I am not trying to map into instances of the concrete classes. See the following:
const myMap: Map<string, typeINeedHelpWith> = new Map()
myMap.set('concrete1string', Concrete1)
myMap.set('concrete2string', Concrete2)
const instantiatedConcrete1 = new myMap.get('concrete1string')(...)
Is there a type definition for typeINeedHelpWith that would let me accomplish this?
const myMap: Map<string, new () => AbstractFoo>, thenconst instantiatedConcrete1 = new (myMap.get('concrete1string'))!()