'Madge skips imported typescript file

I want to print a Javascript dependency graph using madge. It prints all dependencies of a given file successfully. Unfortunately, it skips the imported .ts files and subsequently does not show them in the graph.

Here is my config (.madgerc):

{
    "fileExtensions": ["js", "ts"],
    "tsConfig": "./tsconfig.json",
    "graphVizOptions": {
        "G": {
            "splines": "ortho"
        }
    }
}

Here is my tsconfig.json:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "allowJs": true,
    "preserveConstEnums": true,
    "module": "commonjs",
    "target": "ES2018",
    "moduleResolution": "node",
    "noEmit": true,
    "rootDir": "../"
  }
}

I run madge like so:

madge src/main/path/to/file/view-model.js --warning --debug -i ~/Desktop/graph/view-model.png

It prints:

✔ Image created at /Users/patrick/Desktop/graph/view-model.png

✖ Skipped 1 file

./transform-sponsor

transform-sponsor is imported in my Javascript file like so:

const {transformSponsors} = require('./transform-sponsor');

So my question is, why does madge skip my typescript file. Even though I specifically added a tsconfig file as explained in the documentation?



Solution 1:[1]

Just add --extensions ts to the runned script

Solution 2:[2]

In my experience madge process JavaScript - Files much better then Typescript files. The solution for me was to use madge on the transpiled JavaScript - Files rather than on the original Typescript - src - Files.

I don't really know the answer to your question but I assume that madge is made originally for JavaScript - Files and TypeScript is just a superset of JavaScript thus not so important for the madge - developers (Please don't throw bananas at me when it's not true)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jöcker
Solution 2 Matthias Gwiozda