Reputation: 683
What is the approach to import all the modules from the given folder?
I've read in excellent basarat's "Beginning node.js" book that I can create index file in the folder and make all imports in it.
As an example my index.ts file (located in "common" folder):
import * as moduleA from './moduleA';
import * as moduleB from './moduleB';
And an example of my app.ts file:
import * as common from './common/index';
But this approach doesn't work. What is wrong with my code?
Upvotes: 2
Views: 2049
Reputation: 106640
Right now the files are only being imported into index.ts
, but they are not being exported.
To fix this, you can change the import statements to export statements:
export * from './moduleA';
export * from './moduleB';
Upvotes: 3