【发布时间】:2021-01-28 13:07:34
【问题描述】:
我在我的一个项目中使用 Deno,我想用 typedoc 生成文档。我面临很多依赖问题,因为它们没有得到正确解决,所以 typedoc 失败了。我有以下tsconfig.json:
{
"compilerOptions": {
"module": "amd",
"target": "esnext",
"baseUrl": ".",
"paths": {
"http://*": ["../../../.deno/deps/http/*"],
"https://*": ["../../../.deno/deps/https/*"],
"*.ts": ["*"]
},
"plugins": [
{
"name": "typescript-deno-plugin"
}
]
}
}
paths 中的前两个条目解析了 Deno 的原生模块(如其断言库)。当我使用像 Cheerio 这样的另一个库时,问题就来了,像这样在我的 deps.ts 文件中导入它:
// @deno-types="https://cdn.jsdelivr.net/gh/justjavac/deno_cheerio/cheerio.d.ts"
import cheerio from "https://dev.jspm.io/cheerio/index";
注意:我必须从外部源导入类型,因为在 dev.jspm.io 中声明的类型不起作用,因为它们包含 /// reference 指令。
我有以下typedoc.js 配置文件:
// deno-lint-ignore-file
module.exports = {
out: "./docs-build",
mode: "file",
};
如果我运行typedoc src/,我会收到以下错误:
Using TypeScript 4.0.3 from /home/antonio/.nvm/versions/node/v12.18.1/lib/node_modules/typescript/lib
Error: /home/antonio/manga-api/src/deps.ts(8)
Cannot find module 'https://dev.jspm.io/cheerio/index'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
注意 2:我使用的是 deno,但 typedoc 与 npm 一起全局安装,typescript 和 typescript-deno-plugin。
知道如何使 typedoc 与 Deno 一起正常工作吗?
【问题讨论】: