TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.65k stars 690 forks source link

JSON files are removed from the input files list #1323

Closed jason0x43 closed 4 years ago

jason0x43 commented 4 years ago

Search terms

composite, json, resolveJsonModule

Expected Behavior

Running typedoc on my project with npx typedoc --json docs/apidoc.json should generate a JSON file.

Actual Behavior

Typedoc fails with an error:

Using TypeScript 3.9.5 from /Users/jason/Temp/intern/intern/node_modules/.pnpm/typescript@3.9.5/node_modules/typescript/lib
Error: /Users/jason/Temp/intern/intern/packages/digdug/src/SeleniumTunnel.ts(11)
 File '/Users/jason/Temp/intern/intern/packages/digdug/src/webdrivers.json' is not listed within the file list of project '/Users/jason/Temp/intern/intern/packages/digdug/tsconfig.json'. Projects must list all files or use an 'include' pattern.

The tsconfig.json file did incluede the file in question:

{
  "extends": "@theintern-dev/tsconfig",
  "compilerOptions": {
    "lib": ["es2015"],
    "outDir": "./dist",
    "rootDir": "src",
    "typeRoots": ["./node_modules/@types", "./types"]
  },
  "references": [{ "path": "../common" }],
  "include": ["./src/**/*.ts", "./src/webdrivers.json"]
}

The issue is that the include list isn't being passed directly to the TS compiler. The set of input files is processed by Application.expandInputFiles before being sent to the TS compiler, and expandInputFiles doesn't include JSON files in its expansion. In a composite project, the TS compiler will fail if if the set of input files doesn't include every file that's part of the build (including JSON files). Manually adding the JSON file to the result of expandInputFiles in CliApplication.bootstrap causes the doc build to run successfully.

Steps to reproduce the bug

  1. Create a composite TS project in which one module imports a JSON file
  2. Try to build with typedoc (e.g., typedoc --json docs/apidoc.json)

Environment

Gerrit0 commented 4 years ago

Fix released in 0.17.8