From 9b62f0947dfb88801abad981789adb5939af37cf Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Wed, 25 Dec 2024 16:31:25 -0700 Subject: [PATCH] Fix output specific option specification Resolves #2818 --- CHANGELOG.md | 1 + src/lib/application.ts | 4 ---- src/lib/utils/options/options.ts | 26 -------------------------- src/test/utils/options/options.test.ts | 8 -------- 4 files changed, 1 insertion(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 419b923a7..6b38103a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ title: Changelog - `@include` and `@includeCode` now work in the readme file, #2814. - TypeDoc will now avoid making references to references, #2811. +- Fixed output specific option specification, #2818. - Improved type reference conversion to avoid including defaulted type arguments, #2820. - Improved link resolution logic to prioritize type alias properties with the same symbol over type literal properties within function parameters. diff --git a/src/lib/application.ts b/src/lib/application.ts index 483a52ee5..e17243c19 100644 --- a/src/lib/application.ts +++ b/src/lib/application.ts @@ -361,9 +361,6 @@ export class Application extends AbstractComponent< */ public async convert(): Promise { const start = Date.now(); - // We freeze here rather than in the Converter class since TypeDoc's tests reuse the Application - // with a few different settings. - this.options.freeze(); this.logger.verbose( `Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`, ); @@ -431,7 +428,6 @@ export class Application extends AbstractComponent< public convertAndWatch( success: (project: ProjectReflection) => Promise, ): void { - this.options.freeze(); if ( !this.options.getValue("preserveWatchOutput") && this.logger instanceof ConsoleLogger diff --git a/src/lib/utils/options/options.ts b/src/lib/utils/options/options.ts index c3d68f423..701103889 100644 --- a/src/lib/utils/options/options.ts +++ b/src/lib/utils/options/options.ts @@ -133,20 +133,6 @@ export class Options { return options; } - /** - * Marks the options as readonly, enables caching when fetching options, which improves performance. - */ - freeze() { - Object.freeze(this._values); - } - - /** - * Checks if the options object has been frozen, preventing future changes to option values. - */ - isFrozen() { - return Object.isFrozen(this._values); - } - /** * Take a snapshot of option values now, used in tests only. * @internal @@ -318,12 +304,6 @@ export class Options { configPath?: NeverIfInternal, ): void; setValue(name: string, value: unknown, configPath?: string): void { - if (this.isFrozen()) { - throw new Error( - `Tried to modify an option (${name}) value after options have been frozen.`, - ); - } - const declaration = this.getDeclaration(name); if (!declaration) { const nearNames = this.getSimilarOptions(name); @@ -419,12 +399,6 @@ export class Options { options: ts.CompilerOptions, projectReferences: readonly ts.ProjectReference[] | undefined, ) { - if (this.isFrozen()) { - throw new Error( - "Tried to modify compiler options after options have been frozen.", - ); - } - // We do this here instead of in the tsconfig reader so that API consumers which // supply a program to `Converter.convert` instead of letting TypeDoc create one // can just set the compiler options, and not need to know about this mapping. diff --git a/src/test/utils/options/options.test.ts b/src/test/utils/options/options.test.ts index 6172ad916..c16eb931f 100644 --- a/src/test/utils/options/options.test.ts +++ b/src/test/utils/options/options.test.ts @@ -162,14 +162,6 @@ describe("Options", () => { throws(() => options.isSet("does not exist" as never)); }); - it("Throws if frozen and a value is set", () => { - const options = new Options(new Internationalization(null).proxy); - options.freeze(); - - throws(() => options.setValue("categorizeByGroup", true)); - throws(() => options.setCompilerOptions([], {}, [])); - }); - it("Supports resetting values", () => { const options = new Options(new Internationalization(null).proxy);