From 4855eb6b03d09dc1a7bcbb4fe4cb5c7199dbe065 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Wed, 15 Mar 2023 21:00:18 -0600 Subject: [PATCH] Add --treatValidationWarningsAsErrors Closes #2199 --- CHANGELOG.md | 4 ++++ bin/typedoc | 8 ++++++-- src/lib/utils/options/declaration.ts | 1 + src/lib/utils/options/sources/typedoc.ts | 7 ++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d8db5b8..67adaa5f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +### Features + +- Added `--treatValidationWarningsAsErrors` to turn treat only validation warnings as errors without treating all warnings as errors, #2199. + ### Bug Fixes - Fixed a bug where optional properties were not appropriately marked as optional, #2200. diff --git a/bin/typedoc b/bin/typedoc index 81745b55c..ce835b36e 100755 --- a/bin/typedoc +++ b/bin/typedoc @@ -94,13 +94,17 @@ async function run(app) { return ExitCodes.CompileError; } + const preValidationWarnCount = app.logger.warningCount; app.validate(project); + const hadValidationWarnings = + app.logger.warningCount !== preValidationWarnCount; if (app.logger.hasErrors()) { return ExitCodes.ValidationError; } if ( - app.options.getValue("treatWarningsAsErrors") && - app.logger.hasWarnings() + hadValidationWarnings && + (app.options.getValue("treatWarningsAsErrors") || + app.options.getValue("treatValidationWarningsAsErrors")) ) { return ExitCodes.ValidationError; } diff --git a/src/lib/utils/options/declaration.ts b/src/lib/utils/options/declaration.ts index bb49ce214..b2866b106 100644 --- a/src/lib/utils/options/declaration.ts +++ b/src/lib/utils/options/declaration.ts @@ -157,6 +157,7 @@ export interface TypeDocOptionMap { // Validation treatWarningsAsErrors: boolean; + treatValidationWarningsAsErrors: boolean; intentionallyNotExported: string[]; validation: ValidationOptions; requiredToBeDocumented: (keyof typeof ReflectionKind)[]; diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts index 5272c24e3..04b402c49 100644 --- a/src/lib/utils/options/sources/typedoc.ts +++ b/src/lib/utils/options/sources/typedoc.ts @@ -656,7 +656,12 @@ export function addTypeDocOptions(options: Pick) { options.addDeclaration({ name: "treatWarningsAsErrors", - help: "If set, warnings will be treated as errors.", + help: "If set, all warnings will be treated as errors.", + type: ParameterType.Boolean, + }); + options.addDeclaration({ + name: "treatValidationWarningsAsErrors", + help: "If set, warnings emitted during validation will be treated as errors. This option cannot be used to disable treatWarningsAsErrors for validation warnings.", type: ParameterType.Boolean, }); options.addDeclaration({