ts-morph icon indicating copy to clipboard operation
ts-morph copied to clipboard

Cannot find references outside package

Open fgarcia opened this issue 3 years ago • 1 comments

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

fgarcia avatar Feb 02 '22 20:02 fgarcia

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?

fgarcia avatar Feb 02 '22 20:02 fgarcia