pahen/madge

Typescript baseUrl "./" not recognized

Open

#317 ouverte le 22 mai 2022

Voir sur GitHub
 (0 commentaires) (9 réactions) (0 assignés)JavaScript (322 forks)batch import
cligood first issue

Métriques du dépôt

Stars
 (8 058 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

With tree structure:

.
├── main.ts
├── package-lock.json
├── package.json
├── tsconfig.json
└── utils
    ├── index.ts
    └── toUpper.ts

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true,
    "baseUrl": "."
  },
  "include": ["**/*.ts"],
  "exclude": ["node_modules"]
}

code:

// utils/toUpper.ts
export const toUpper = (str: string) => {
  return str.toUpperCase();
};

// utils/index.ts
export * from "./toUpper";

// main.ts
import { toUpper } from "utils"; // notice i am not using here ./utils but counting on typescripts baseUrl value
console.log(toUpper("madge"));

and when I run npx madge --ts-config ./tsconfig.json --extensions ts --warning --circular ./, I will get result

Processed 3 files (412ms) (1 warning)

✔ No circular dependency found!

✖ Skipped 1 file

utils

Why is my utils/index.ts skipped? I noticed if I change tsconfig's baseUrl to the result of pwd in the same dir as tsconfig.json, like so

    "baseUrl": "/Users/testing/typescript/madge"

then utils/index.ts won't be skipped and everything would work fine, or if I would restructure main.ts and utils inside src and set baseUrl to ./src it would also work fine.

How can I make madge with tsconfig's "baseUrl": "." to not skip utils?

Guide contributeur