dsherret / dsherret/ts-morph

Cannot find references outside package

Open
#1,242 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

**Describe the bug**

Version: 13.0.3

**To Reproduce**

I have a monorepo with multiple packages. My tsconfig looks like this:

```json
{
"include": ["packages/*/src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"],
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": false,
}
}
```

```ts
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

Contributor guide

Open the contributing guide

Research direction

Reproduce the monorepo case using the provided tsconfig and the ts-morph Project entry point. Inspect how getSourceFile('packages/core/src/panda/index.ts').getReferencingSourceFiles() resolves imports across packages; done means references from packages outside @app/core are included as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.