From 8edb17c5bf08f6306664ce16d3123605bef9c2b3 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Sat, 16 May 2020 20:30:23 -0600 Subject: [PATCH] fix: TypeDoc fails to resolve @types packages outside of cwd Closes #1300 --- src/lib/utils/options/sources/typescript.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/utils/options/sources/typescript.ts b/src/lib/utils/options/sources/typescript.ts index 8dc70e76e..8350ba128 100644 --- a/src/lib/utils/options/sources/typescript.ts +++ b/src/lib/utils/options/sources/typescript.ts @@ -17,10 +17,7 @@ const IGNORED_OPTIONS = [ 'inlineSources', 'removeComments', 'incremental', - 'tsBuildInfoFile', - // This is not a TS option, but TypeScript will add it to the compiler options - // so we need to remove it or TypeDoc will error since it isn't declared. - 'configFilePath' + 'tsBuildInfoFile' ] as const; /** @@ -43,6 +40,16 @@ export function addTSOptions(container: Options) { container.addDeclarations(_ts.optionDeclarations .filter(decl => !IGNORED.has(decl.name)) .map(createTSDeclaration)); + + // This isn't really an option, and should never be set by users, but it shows up in the + // return value from ts.parseJsonConfigFileContent and is used to find @types packages. + // It is only needed if the project is outside of the cwd. See GH#1300. + container.addDeclarations([{ + name: 'configFilePath', + type: ParameterType.String, + scope: ParameterScope.TypeScript, + help: '' + }]); } function createTSDeclaration(option: _ts.CommandLineOption): DeclarationOption {