-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ignoreCompilerErrors #1403
Comments
The main problem with ignoreCompilerErrors I have is that everyone uses it - and then don't turn it off to make sure docs still build when typedoc crashes due to a bad setup... I'm not basing this off a guess - it's based off several months of tracking issues. Approximately 15% of them were due to compiler errors. That said, for advanced users I'm not completely against making this possible. Refactoring This refactoring would also make it possible, and in fact fairly straightforward, to use the incremental program watcher API to allow re-running TypeDoc without waiting for type checking. |
@Gerrit0 your point is totally understandable . though weird. Myself obviously build my lib with tsc thus with errors report. |
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"); |
@Gerrit0 why am I facing with a "blank" page? Version: TypeDoc 0.20.0-beta.16 |
The above script is broken in beta 19+, I had to change the signatures of |
I utilizedthe --ignoreCompilerErrors flag to generate docs on a subset of the codebase - allowing references to excluded types to effectively dangle. This made it possible to specify a naming convention for specific files to have docs generated (in my case, a bunch of shared models) |
That shouldn't be necessary in 0.20 anymore since we properly use the compiler's functions to initialize with all files, then only document what's requested. |
This really doesn't seem to play well with my setup unfortunately. I'm utilizing composite projects and project references, which is probably where the issues are coming from. I tried the following:
I can't think of anything else to try & I'm forced to upgrade for typescript 4.1 support that's only in the beta. |
Can you point TypeDoc at the root tsconfig that references both projects? I've admittedly never used project references, and have never had a good test case to ensure typedoc works properly with it... if your project is open source, sounds like it might be a good test case for me to look at. |
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 |
Thanks! I will take a closer look either tomorrow night or this weekend, with the goal of making |
Thanks again for the example @berickson1! 0.20.0-beta.26 was just published and adds support for project references. I think this should solve your issue. There are some notes about how it works and potential gotchas in #1414. |
Just stumbled upon this as well: Our project uses dependencies from an internal Nexus repository. The API docs are generated as GitLab Pages, but in the GitLab CI environment we currently do not have access to the Nexus repository. Before, we used to just install a few select dependencies there and generate the API docs while setting After upgrading to 0.20, there are a lot of TypeScript errors caused by dependencies we cannot install in the environment we generate the API docs in, so we are currently stuck on 0.17.0-3, unless we can convince our IT department to set up a proper Nexus authentication 😕 Is using a custom script like in #1403 (comment) still possible with the 0.20 release version? Edit: I think I got it working, thanks a lot for the template above! My code: // @ts-check
const td = require('typedoc');
const ts = require('typescript');
const typedocJson = require('typedoc.json');
/**
* @param {Object} options
* @param {string} options.entryPoint
* @param {string} options.outDir
* @param {Partial<import('typedoc').TypeDocOptions>} [typeDocOptions]
*/
exports.createTypeScriptApiDocs = async ({ entryPoint, outDir }, typeDocOptions) => {
const app = new td.Application();
app.options.addReader(new td.TSConfigReader());
app.bootstrap({
...typedocJson,
entryPoints: [entryPoint],
tsconfig: 'tsconfig.json',
...typeDocOptions,
});
const program = ts.createProgram(
app.options.getFileNames(),
app.options.getCompilerOptions()
);
const project = app.converter.convert(
app.expandInputFiles(app.options.getValue('entryPoints')),
program
);
if (project) {
await app.generateDocs(project, outDir);
} else {
throw new Error(`Error creating the TypeScript API docs for ${entryPoint}.`);
}
}; |
I cannot make my mono repo (with And honestly, I don't see what is the gain of removing |
It eliminated about 30% of bug reports. When your code has compiler errors, TS does not always honor the API contract, so TypeDoc's code was becoming overly cluttered with checks regarding things that might not be true if there were errors. You might be interested in #1567, which looks like it might do some good things for monorepos. |
I take from this that typedoc will not produce even partial output for a project that doesn't completely typecheck? |
That is correct. |
My main problem is that I am encountering microsoft/TypeScript#38383 again when I try to upgrade from |
Having this option wouldn't fix that issue... and that's in the TypeScript repo, if there's a crash with a version of TS that TypeDoc officially supports (as noted by the peer dependencies) in 0.20, then to fix it I'll need a bug report with a reproduction |
@Gerrit0 Yes I understand, I am going to wait until 4.3 support roles around to make sure that the issue continues. |
I have another strange usecase, we're using typedoc to generate docs for AssemblyScript which looks like but isn't typescript so therefor doesn't compile, however the docs typedoc generate look great. Unfortunately the workspaces ticket doesn't solve generating docs in my case. I'll have a look at the custom script but I just wanted to add another vote towards bringing back the flag. |
It seems that in recent versions, the signature of Is there a way to ignore compiler errors on TypeDoc 0.22.4? |
In 0.22, you want |
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);
} |
Against my better judgement, I've decided to give this option another shot. #1975 introduces a |
How to use it in my project |
@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 #1364 (comment)
The text was updated successfully, but these errors were encountered: