How to properly exclude test files from tsdoc / typedoc

2.7k Views Asked by At

I am testing out some various documentation engines, and I'd like to try typedoc for our large project. We have various test files (somefile.test.ts or someotherfile.test.tsx) throughout our project. I'm struggling to get typedoc to ignore these files. I did npm i -D typedoc, then in my tsconfig.json

{
  "compilerOptions": {
    "configOptions": "some_options"
  },
  "include": ["src"],
  "typedocOptions": {
    "out": "docs",
    "entryPoints": "src/index.tsx",
    "exclude": [
      "**/*.test.ts*",
      "**/*.test.tsx*"
    ]
  }
}

Then I run my npm command "tsdoc": "typedoc" - npm run tsdoc. Typedoc runs through my files and finds an absolute ton of typescript linting errors in my testing files, and so it fails to run. (We recently updated our @types/jest, so eslint and ts are complaining about things like Property 'toEqual' does not exist on type 'Assertion' and Property 'toMatchSnapshot' does not exist on type 'Assertion'. eslint and ts complain about these things, but it doesn't prevent the tests from running. But what is wrong with my typedocOptions that it is not correctly ignoring these files?

1

There are 1 best solutions below

3
On

This is a total shot in the dark, but I'm going to guess that typedoc runs tsc before it attempts to generate the documentation, to create the linkages between files. It might not get to the point of checking which files to exclude if tsc/eslint are giving it errors.

I'd recommend looking into why the Jest upgrade is blowing things up. Once the compiler/linting errors are gone, I imagine typedoc will cooperate. You could also tell tsc/eslint to ignore those files, but I imagine that not compiling the test files will cause further problems down the line.