Skip to content

JSON files are removed from the input files list #1323

@jason0x43

Description

@jason0x43

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

  • Typedoc version: 0.17.7
  • TypeScript version: 3.9.5
  • Node.js version: 14.4.0
  • OS: macOS 10.15.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions