Having trouble accessing types defined in another project within a mono-repo structure. Here's how the projects are organized:
-- packages
-- project-a
-- tsconfig.json
-- project-b
-- tsconfig.json
-- shared
-- src
-- UserModel.ts
-- index.ts
-- tsconfig.json
-- tsconfig.base.json
-- package.json
-- tsconfig.json (No changes made here)
tsconfig.base.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"noEmit": false,
"composite": true
},
"files": [],
"references": [{ "path": "./shared" }]
}
Shared tsconfig.json
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"baseUrl": "./",
"rootDir": "src",
"composite": true,
"experimentalDecorators": true,
"declaration": true,
"declarationMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__e2e__/*"]
}
Project-a tsconfig.json
{
"extends": ".. /tsconfig.base.json",
"compileOnSave": true,
"compilerOptions": {
"baseUrl": "./",
"outDir": ". /dist/out-tsc",
"sourceMap": true,
"downlevelIteration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"module": "es2020",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"jsx": "react",
"lib": [
"es2018",
"dom"
],
"paths": {
"@shared": ["../shared/src"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
},
"references": [
{ "path": "../shared" }
]
}
Despite these configurations, unable to reference UserModel.ts
from the shared project in project-a. The IDE does not recognize it.
Import line in project-a:
import {UserModel} from '@shared/UserModel'; //Tried 'shared/src/UserModel' as well
How can I resolve this issue?