madge icon indicating copy to clipboard operation
madge copied to clipboard

Mixing javascript and typescript imports doesn't work with compilerOptions.paths

Open igrayson opened this issue 3 years ago • 2 comments

Hello! This is a continuation of https://github.com/pahen/madge/issues/207. This is more of an FYI for madge users, as the fix should happen in filing-cabinet.

This problem occurs with a tsconfig.json that looks like this:

// ./tsconfig.json
{
  "compilerOptions": {
    "module": "CommonJS", // important to set, madge defaults to AMD.
    "allowJs": true,
    "paths": { "@/*": ["src/at/*"] },
  }
}

and a project layout that looks like this:

// ./src/at/b/index.ts or ./src/at/b.ts
export const foo = 'bar';
// ./src/a.js
import { foo } from '@/b';
console.log(foo);

And to reproduce:

$ madge --ts-config tsconfig.json --warning src/a.js
Processed 1 file (420ms) (1 warning)

a.js

✖ Skipped 1 file

@/b

igrayson avatar Jan 05 '22 18:01 igrayson

See https://github.com/dependents/node-filing-cabinet/pull/103

igrayson avatar Jan 05 '22 19:01 igrayson

@igrayson were you able to come up with a solution for this?

ninjz avatar Aug 04 '23 04:08 ninjz