ts-morph
ts-morph copied to clipboard
getModuleSpecifierSourceFile return undefined for import with
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.
@teyma I am having the same issues, using the examples from the docs I am getting undefined. However I am running code in VS plugin env... Did you managed to make it work?