typedoc: Support for ignoreCompilerErrors

@Gerrit0 could i ask to bring back ignoreCompilerErrors ? In my case i omit on purpose a lot of typings files to make typdoc faster. It is on purpose and i know it wont have any consequence on my doc. I could really use that flag. You could set it to false by default. Thanks

_Originally posted by @farfromrefug in https://github.com/TypeStrong/typedoc/issues/1364#issuecomment-732103433_

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 14
  • Comments: 26 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Against my better judgement, I’ve decided to give this option another shot. #1975 introduces a --skipErrorChecking option, which is available in 0.23.11.

I cannot make my mono repo (with ./apps and ./libs) work with multiple tsconfig.json. I will be stuck at the old version as ignoreCompilerErrors is removed.

And honestly, I don’t see what is the gain of removing ignoreCompilerErrors as you can default it to false. It’s the users’ conscious decision to turn it on.

Thank you! With this, I got @kryops’s function working with TypeDoc 0.22. Here it is, in case someone else is in the same situation (converted it to TypeScript):

import path from 'path';
import { TSConfigReader, Application as TypeDocApplication, TypeDocOptions } from 'typedoc';

import typedocJson from './typedoc.json';

export async function createTypeScriptApiDocs(
  { entryPoint, outDir }: { entryPoint: string, outDir: string },
  typeDocOptions?: Partial<TypeDocOptions>,
) {
  const app = new TypeDocApplication();
  app.options.addReader(new TSConfigReader());

  app.bootstrap({
    ...typedocJson,
    entryPoints: [entryPoint],
    tsconfig: path.join(__dirname, '../tsconfig-typedoc.json'),
    ...typeDocOptions,
  });

  // This is the part that seems to skip compile errors
  // (normally we would call `app.convert()` here)
  const project = app.converter.convert(app.getEntryPoints() ?? []);

  if (!project) {
    throw new Error(`Error creating the TypeScript API docs for ${entryPoint}.`);
  }

  await app.generateDocs(project, outDir);
}

That is correct.

It’s not a public project unfortunately. I do have an example that utilizes project references where this same behaviour manifests. I added a branch with typedoc

https://github.com/berickson1/project-references-demo/tree/typedoc

From there you can run npm run doc and it’ll only generate a doc for the readme.

0.20.0-beta.16 contains the necessary changes to be able to run typedoc with a script that acts like ignoreCompilerErrors used to.

Just reiterating - a setup like this is officially unsupported. If you use this, and encounter a bug, make sure the bug can be reproduced with a version that does check for compiler errors.

// @ts-check

const td = require("typedoc");
const ts = require("typescript");

const app = new td.Application();
// For reading typedoc.json - optional
app.options.addReader(new td.TypeDocReader());
// For reading tsconfig.json - essential
app.options.addReader(new td.TSConfigReader());

app.bootstrap({
    // can put other options here too, or in typedoc.json/tsconfig.json
    tsconfig: "tsconfig.json",
    entryPoints: ["src/index.ts"],
});

const program = ts.createProgram(
    app.options.getFileNames(),
    app.options.getCompilerOptions()
);

// Application.convert checks for compiler errors here.

const project = app.converter.convert(
    app.expandInputFiles(app.options.getValue("entryPoints")),
    program
);

app.generateDocs(project, "./docs");
app.generateJson(project, "./docs.json");