From 0985616f55e234747099cf14efac06c85294183c Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Mon, 4 Sep 2023 12:32:20 -0600 Subject: [PATCH] Handle projects without tsconfig files Resolves #2304 --- CHANGELOG.md | 1 + src/lib/utils/entry-point.ts | 14 ++++++++++---- src/lib/utils/options/readers/tsconfig.ts | 8 -------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99f92dcd2..cef1db6b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Added `stripYamlFrontmatter` config option to remove YAML frontmatter from README.md, #2381. - Added `--excludeCategories` config option to remove reflections present in any excluded category, #1407. +- If no tsconfig.json file is present, TypeDoc will now attempt to compile without setting any compiler options, #2304. - Navigation is now written to a JS file and built dynamically, which significantly decreases document generation time with large projects and also provides large space benefits. Themes may now override `DefaultTheme.buildNavigation` to customize the displayed navigation tree, #2287. diff --git a/src/lib/utils/entry-point.ts b/src/lib/utils/entry-point.ts index df77ea8bd..79b982a8c 100644 --- a/src/lib/utils/entry-point.ts +++ b/src/lib/utils/entry-point.ts @@ -183,7 +183,7 @@ function getEntryPointsForPaths( logger: Logger, inputFiles: string[], options: Options, - programs = getEntryPrograms(logger, options), + programs = getEntryPrograms(inputFiles, logger, options), ): DocumentationEntryPoint[] { const baseDir = options.getValue("basePath") || deriveRootDir(inputFiles); const entryPoints: DocumentationEntryPoint[] = []; @@ -234,7 +234,7 @@ export function getExpandedEntryPointsForPaths( logger: Logger, inputFiles: string[], options: Options, - programs = getEntryPrograms(logger, options), + programs = getEntryPrograms(inputFiles, logger, options), ): DocumentationEntryPoint[] { return getEntryPointsForPaths( logger, @@ -284,9 +284,15 @@ function expandGlobs(inputFiles: string[], exclude: string[], logger: Logger) { return result; } -function getEntryPrograms(logger: Logger, options: Options) { +function getEntryPrograms( + inputFiles: string[], + logger: Logger, + options: Options, +) { const rootProgram = ts.createProgram({ - rootNames: options.getFileNames(), + rootNames: options.getFileNames().length + ? options.getFileNames() + : inputFiles, options: options.getCompilerOptions(), projectReferences: options.getProjectReferences(), }); diff --git a/src/lib/utils/options/readers/tsconfig.ts b/src/lib/utils/options/readers/tsconfig.ts index 8f620e0a8..e6df93df8 100644 --- a/src/lib/utils/options/readers/tsconfig.ts +++ b/src/lib/utils/options/readers/tsconfig.ts @@ -21,7 +21,6 @@ import { tsdocModifierTags, } from "../tsdoc-defaults"; import { unique } from "../../array"; -import { EntryPointStrategy } from "../../entry-point"; import { findTsConfigFile, readTsConfig } from "../../tsconfig"; function isSupportForTags(obj: unknown): obj is Record<`@${string}`, boolean> { @@ -82,13 +81,6 @@ export class TSConfigReader implements OptionsReader { logger.error( `The tsconfig file ${nicePath(file)} does not exist`, ); - } else if ( - container.getValue("entryPointStrategy") !== - EntryPointStrategy.Packages - ) { - logger.warn( - "No tsconfig file found, this will prevent TypeDoc from finding your entry points.", - ); } return; }