dsherret / dsherret/ts-morph

getReferencedSourceFiles does not return paths from custom path mapping

Open
#1,188 3 comments 3 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**

```typescript
const c = project.getSourceFiles().map((a) => a.getReferencedSourceFiles());
```

Will only return relative file references. For example https://github.com/microsoft/vscode/blob/main/src/tsconfig.base.json#L16, and files imported using this custom path will not show in results.

The file I am testing is https://github.com/microsoft/vscode/blob/main/src/vs/editor/editor.main.ts, which will have _no_ results.

**Describe the solution you'd like**

Return all references.

**Describe alternatives you've considered**

I don't know of a good alternative.

Side note: I am trying to navigate from one source file to another based on import paths. If someone has a good solution here, I am all ears.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with src/vs/editor/editor.main.ts and the custom path mapping in src/tsconfig.base.json, starting from getReferencedSourceFiles(). Trace how mapped imports are resolved and verify that the method returns both relative and custom-mapped references. There are no implementation files or tests named in the issue.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.