11import {
2+ deepStrictEqual ,
23 deepStrictEqual as equal ,
34 notDeepStrictEqual as notEqual ,
45 ok ,
56} from "assert" ;
6- import type { Application } from "../lib/application" ;
7+ import { Application } from "../lib/application" ;
8+ import { ApplicationEvents } from "../lib/application-events" ;
79import {
810 DeclarationReflection ,
911 ProjectReflection ,
@@ -18,6 +20,7 @@ import {
1820 IntrinsicType ,
1921} from "../lib/models" ;
2022import type { InlineTagDisplayPart } from "../lib/models/comments/comment" ;
23+ import { ParameterType , TypeDocOptionMap } from "../lib/utils" ;
2124import { getConverter2App } from "./programs" ;
2225import type { TestLogger } from "./TestLogger" ;
2326
@@ -725,6 +728,40 @@ export const issueTests: {
725728 ) ;
726729 } ,
727730
731+ gh2024 ( ) {
732+ const name = "objectOptions" as keyof TypeDocOptionMap ;
733+ const defaultValue = {
734+ neverChange : "ok" ,
735+ foo : "foo" ,
736+ } ;
737+ const app = new Application ( ) ;
738+ app . options . addDeclaration ( {
739+ help : "Test option parsing with default values from plugins" ,
740+ name,
741+ type : ParameterType . Object ,
742+ defaultValue,
743+ } ) ;
744+ deepStrictEqual ( app . options . getValue ( name ) , defaultValue ) ;
745+ app . options . setValue ( name , { foo : "bar" } ) ;
746+ const newVal = app . options . getValue ( name ) as typeof defaultValue ;
747+ equal ( newVal . foo , "bar" ) ;
748+ equal ( newVal . neverChange , "ok" ) ;
749+ app . options . setValue ( "out" , "testOutString" ) ;
750+ app . on ( ApplicationEvents . BOOTSTRAP_END , ( ) => {
751+ equal ( app . options . getValue ( "out" ) , "" ) ;
752+ app . options . setValue ( "out" , "testOutString" ) ;
753+ app . options . setValue ( name , { foo : "foo" } ) ;
754+ } ) ;
755+ app . bootstrap ( ) ;
756+ app . options . setValue ( name , { } ) ;
757+ app . convert ( ) ;
758+ deepStrictEqual ( app . options . getValue ( name ) , defaultValue ) ;
759+ equal (
760+ app . options . getValue ( "out" ) . trim ( ) . endsWith ( "testOutString" ) ,
761+ true
762+ ) ;
763+ } ,
764+
728765 gh2031 ( project , logger ) {
729766 const sig = query ( project , "MyClass.aMethod" ) . signatures ! [ 0 ] ;
730767 const summaryLink = sig . comment ?. summary [ 0 ] ;
0 commit comments