gpt4 book ai didi

Madge 跳过导入的 typescript 文件

转载 作者:行者123 更新时间:2023-12-05 05:07:30 28 4
gpt4 key购买 nike

我想使用 madge 打印 Javascript 依赖关系图。它成功打印给定文件的所有依赖项。遗憾的是,它会跳过导入的 .ts 文件,随后不会在图中显示它们。

这是我的配置(.madgerc):

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

这是我的tsconfig.json:

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

我像这样运行 madge:

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

它打印:

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

✖ Skipped 1 file

./transform-sponsor

transform-sponsor 像这样导入到我的 Javascript 文件中:

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

所以我的问题是,为什么 madge 会跳过我的 typescript 文件。尽管我按照 documentation 中的说明专门添加了一个 tsconfig 文件?

最佳答案

只需在运行的脚本中添加--extensions ts

关于Madge 跳过导入的 typescript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59066762/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com