ts-morph
ts-morph copied to clipboard
Cannot find references outside package
Describe the bug
Version: 13.0.3
To Reproduce
I have a monorepo with multiple packages. My tsconfig looks like this:
{
"include": ["packages/*/src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"],
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": false,
}
}
import { Project } from "ts-morph";
let project = new Project({
tsConfigFilePath: '/app/tsconfig.tsmorph.json',
})
// This seems to be OK, all files are listed
console.log(project.getSourceFiles().map(x => x.getFilePath())
let found = project
.getSourceFile('packages/core/src/panda/index.ts')
.getReferencingSourceFiles()
Expected behavior
If get all references to @app/core/panda within @app/core, however references from packages outside @app/core are not listed
OK, found my answer shortly after. Looks like I had to getSourceFile not from the index.ts but from the index.d.ts to find references from other packages... which is kind of logic, but also painful. Am I using ts-morph the wrong way, or is this the way it is supposed to be?