How can TypeScript be used to access multiple classes from different files as an array?
Consider the following folder structure:
├── index.ts
└── models
├── index.ts
├── image.entity.ts
└── user.entity.ts
In the file image.entity.ts:
export class Image { }
In the file user.entity.ts:
export class User { }
Within models/index.ts:
export * from './image.entity';
export * from './user.entity';
To achieve the desired output in index.ts:
import * as models from './models/index';
// Accessing elements in models as an iterable array
console.log(models.length) // Output: 2