My project structure is as below:
Some ASP.NET Dir
-projects/lib1
/lib2
-src (Angular app)
-package.json
-angular.json
In lib2:
/src
-lib
-interfaces
-ICard.ts
-services
-ui-components
-card
-card.component.ts
ui-components.module.ts
package.json (UI component's)
public_api.ts (UI component's)
public-api.ts
package.json
tsconfig.lib.json
src's public_api.ts:
export * from './lib/lib.service';
export * from './lib/lib.component';
export * from './lib/lib.module';
export { ICard } from './lib/interfaces/ICard';
In card.component.ts:
import { Component, OnInit, ViewEncapsulation, Input } from '@angular/core';
import { ICard } from '../../interfaces/ICard';
import { CommonHelperService } from '../../services/common-helper.service';
@Component({
selector: 'lib-card',
templateUrl: './card.component.html',
styleUrls: ['./card.component.scss'],
encapsulation: ViewEncapsulation.ShadowDom,
})
export class CardComponent implements OnInit {
@Input() Card: ICard;
constructor(private commonHelper: CommonHelperService) {}
ngOnInit(): void {
this.Card = this.commonHelper.DefaultCardFallback;
}
}
In tsconfig.lib.json
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
I am getting this error when I build this lib:
error TS6059: File 'ASP.NET/projects/lib/src/lib/interfaces/ICard.ts' is not under 'rootDir' 'ASP.NET\projects\lib\src\lib\ui-components'. 'rootDir' is expected to contain all source files.
Why does the typescript not include the interface? What should be the right way for the interface exports?