If my file structure looks like this:
- app
- models
- model1.ts
- model2.ts
- model3.ts
- index.ts
- services
- serviceGroup1
- serviceGroup1Service1.ts
- serviceGroup1Service2.ts
- index.ts
- serviceGroup2
- serviceGroup3
- index.ts
- models
In the tsconfig.json file:
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "/",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"outDir": "../dist/",
"rootDir": ".",
"sourceMap": true,
"target": "es5",
"inlineSources": true
}
How can I make all models public and import them like this in serviceGroup1Service1.ts:
import * as models from 'models';
Updated file tree
Updated files
I added new barrels to system.config.ts
'app',
'app/models',
'app/services'
When trying to use it in serviceGroup1Service1.ts
import * from 'app/models'
I get an error saying "Cannot find module 'app/models'
However, importing components like this works fine:
import { Component } from '@angular/core'
How can I do it for my components?