I'm working on an Angular project. I have a library tools and a project example. My project structure looks like this (Monorepo)
root
|-- projects
| |-- example
| | |-- src
| | | `-- app
| | | |-- app.module.ts
| | | `-- view
| | | `-- main.component.ts
| | `-- tsconfig.app.json
| `-- tools
`-- tsconfig.json
My tsconfig.json looks like this
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": false,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
}
}
And my tsconfig.app.json
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/app",
"types": [],
"allowJs": true,
"experimentalDecorators": true,
"traceResolution": true,
"paths": {
"tools": [
"dist/tools/tools",
"dist/tools"
],
"@example/*": [
"projects/example/src/app/*",
"projects/example/src/app/view/features/*",
"projects/example/src/app/core/guards/index.ts",
"projects/example/src/app/core/components/index.ts",
"projects/example/src/app/core/model/index.ts",
"projects/example/src/app/core/services/index.ts",
"projects/example/src/app/view/features/f1/store/index.ts",
"projects/example/src/app/view/features/f2/store/index.ts",
"projects/example/src/app/view/features/f3/store/index.ts"
]
}
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}
When I try to import tools in my app.module.ts, it works fine. But when I import it in any of the feature/sub modules, say main.component.ts, IntelliJ marks it as an error.
TS2307: Cannot find module 'tools' or its corresponding type declarations
I tried to run tsc --project projects/example/tsconfig.app.json in the command line and examined the output, I found that it was resolved successfully
Module name 'tools' was successfully resolved
I'm clueless and out of solutions!