I managed to successfully build, link, and import my library into my main application. However, I encountered an issue where the return type of the RxJs Observable from my library's node_modules is different from that in the main application's node_modules:
Type 'import("D:/KeySystems-Angular-Packages/node_modules/rxjs/internal/Observable").Observable<boolean>' is not assignable to type 'import("d:/KeySystems-WebCustomerPortal/node_modules/rxjs/internal/Observable").Observable<boolean>'.
Types of property 'source' are incompatible.
Type 'import("D:/KeySystems-Angular-Packages/node_modules/rxjs/internal/Observable").Observable<any>' is not assignable to type 'import("d:/KeySystems-WebCustomerPortal/node_modules/rxjs/internal/Observable").Observable<any>'.ts(2322)
The package.json file from my Angular Library's Workspace looks like this:
{
"name": "key-systems-core-workspace",
"version": "0.0.0",
"scripts": {},
"dependencies": {
// Dependencies list here
},
"devDependencies": {
// Dev dependencies list here
}
}
Here is the configuration for the Library project itself:
{
"name": "state-management",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^7.0.0",
"@angular/core": "^7.0.0",
"rxjs": "^6.5"
}
}
the library's workspace's tsconfig:
{
// Tsconfig settings here
}
my application's tsconfig:
{
// Application tsconfig details
}
Peer dependencies should be specified in the tsconfig path according to my understanding. Initially, I included them in the library's tsconfig but faced issues, so I also added them to the application's tsconfig.
This discrepancy causes the following error:
getBusinessClaims(): Observable<IBusinessClaims> {
return this.stateService.get<IBusinessClaims>(ClaimType.Business);
}