Within my coding project, I have a specific Users
class that is being exported from the file named Users.ts
export default class Users {}
This Users.ts
file is then exported from another file called index.ts
:
// classes
export {default as Users} from './Users'
In a third file labeled Foo.ts
, my goal is to dynamically create instances of all the exported classes from index.ts
and incorporate them as properties within that class:
import * as classes from './index'
class Foo {
constructor() {
const httpClient = new HttpClient()
}
_addClasses() {
for (const classNames in classes) {
this[classNames] = new classes[classNames](this.httpClient);
}
}
}
My inquiry revolves around how to properly assign types to Foo
, ensuring accurate autocompletion functionalities are available in the IDE when using .users
like so:
new Foo(new HttpClient).users