dsherret / dsherret/ts-morph

getModuleSpecifierSourceFile return undefined for import with

Open
#1,508 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

Hi, I'm working on project that verify the architecture of other projects.
I'm using ts-morph to read files and get imports from them.

Everything works fine expect for some imports that could not be found.

I'm using the method getModuleSpecifierSourceFile that returns undefined.

This is an example of an import that does not work.
```
import * as path from 'path';
```

This is how i initialize the project

```
const project = new Project({
tsConfigFilePath: 'tsconfig.json',
});

project.addSourceFilesAtPaths('src/**/*.ts');
```

In the compiler options in my tsconfig, I'm using :
```
"module": "commonjs"
```

I tried to add "moduleResolution": "Node", but it didn't change anything.

Thanks in advance for your help.

Contributor guide

Open the contributing guide

Research direction

Reproduce the report with the Project initialization, tsconfig.json using CommonJS, and the `import * as path from 'path'` example, then inspect `getModuleSpecifierSourceFile` and the TypeScript module-resolution result. Done means the behavior for this import is explained and a regression test or documented limitation covers the observed result.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.