typescript - 如何从 tsdoc / typedoc 中正确排除测试文件
问题描述
我正在测试一些不同的文档引擎,我想为我们的大型项目尝试 typedoc。我们在整个项目中都有各种测试文件(somefile.test.ts
或)。someotherfile.test.tsx
我正在努力让 typedoc 忽略这些文件。我做了npm i -D typedoc
,然后在我的 tsconfig.json
{
"compilerOptions": {
"configOptions": "some_options"
},
"include": ["src"],
"typedocOptions": {
"out": "docs",
"entryPoints": "src/index.tsx",
"exclude": [
"**/*.test.ts*",
"**/*.test.tsx*"
]
}
}
然后我运行我的 npm 命令"tsdoc": "typedoc"
- npm run tsdoc
。Typedoc 遍历我的文件并在我的测试文件中发现大量的打字稿 linting 错误,因此它无法运行。(我们最近更新了我们的@types/jest
, 所以 eslint 和 ts 抱怨Property 'toEqual' does not exist on type 'Assertion'
和Property 'toMatchSnapshot' does not exist on type 'Assertion'
.eslint 和 ts 抱怨这些事情,但这并不能阻止测试运行。但是我的问题typedocOptions
是它没有正确忽略这些文件?
解决方案
这完全是在黑暗中拍摄,但我猜测它会在它尝试生成文档之前typedoc
运行,以创建文件之间的链接。如果/给出错误tsc
,它可能无法检查要排除的文件。tsc
eslint
我建议调查一下为什么 Jest 升级会搞砸事情。一旦编译器/检查错误消失,我想typedoc
会合作。您也可以告诉tsc
/eslint
忽略这些文件,但我想不编译测试文件会导致进一步的问题。
推荐阅读
- r - R - 可反应 - groupBy - 在顶部显示总计
- r - 如何让节点链接到 URL(visNetwork,R)
- awk - awk:如果条件不满足,则设置一个变量
- php - 为什么 Firefox 浏览器会抛出 PHP 代码错误?
- containers - 在 cython 中使用 C++ 容器
- ios - 通过 Fastlane 辞职后出现错误 ITMS-90046
- html - 如何旋转 svg 并将其放置在屏幕的左侧?
- javascript - 使用 Blazor Server 时如何添加客户端 DOM javascript 事件处理程序?
- pandas - 将 numpy 数组合并到 pandas 数据帧中(但数组是一种奇怪的格式)
- ruby - 如何使用读取器和设置器在 Ruby 哈希中添加和检索元素