pahen/madge

Typescript baseUrl "./" not recognized

Open

#317 aberto em 22 de mai. de 2022

Ver no GitHub
 (0 comments) (9 reactions) (0 assignees)JavaScript (322 forks)batch import
cligood first issue

Métricas do repositório

Stars
 (8.058 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

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?

Guia do colaborador