Using ts-morph to locate all the source files is crucial. The code snippet below demonstrates this:
The key code for this operation is as follows:
let tsmorph = require('ts-morph')
const project = new tsmorph.Project();
project.addSourceFilesAtPaths("../../tsconfig.json");
const sourceFiles = project.getSourceFiles();
console.log(sourceFiles) // This results in an empty array: []
Upon running
npx ts-node test/unit/ts-morph-test.ts
, the outcome is also an empty array.
Wondering why the correct results cannot be fetched?
You can view my code on CodeSandbox at the following link: https://codesandbox.io/s/2ntc8q
Examining the test project's code structure reveals that it clearly contains TypeScript files.