@@ -190,17 +190,30 @@ const fold = F.fold<string>((x, ix, input) => {
190190 const REST = 'rest' in option && typeof option . rest === 'string' ? `{ [x: string]: ${ option . rest } }` : ''
191191 const OPT = Object . entries ( original . entries ) . filter ( ( [ , v ] ) => hasOptional ( v ) ) . map ( ( [ k ] ) => k )
192192 const xs = Object . entries ( option . entries ) . map (
193- ( [ k , v ] ) => {
194- const description = getDescription ( original [ k ] )
193+ ( [ k , value ] ) => {
194+ const originalValue = original . entries [ k ]
195+ const description = v . getDescription ( originalValue )
196+ const title = v . getTitle ( originalValue )
197+ const default_ = v . getDefault ( originalValue )
198+ const metadata = v . getMetadata ( originalValue )
199+ const $description = description === undefined ? null : ` * @description ${ escapeJsDoc ( description ) } `
200+ const $title = title === undefined ? null : ` * @title ${ escapeJsDoc ( title ) } `
201+ const $default = default_ === undefined ? null : ` * @default ${ escapeJsDoc ( JSON . stringify ( default_ , null , 2 ) . split ( '\n' ) . map ( ( line ) => ` * ${ line } ` ) . join ( '\n' ) ) } `
202+ const $metadata = Object . keys ( metadata ) . length === 0 ? null : ` * @metadata \n${ JSON . stringify ( metadata , null , 2 ) . split ( '\n' ) . map ( ( line ) => ` * ${ line } ` ) . join ( '\n' ) } `
203+ const hasJsDoc = preserveJsDocsEnabled ( ix ) && ( $default !== null || $description !== null || $title !== null || $metadata !== null )
204+
195205 const READONLY = isReadonly ( original . entries [ k ] ) ? 'readonly ' : ''
196- const JSDOCS = description == null || ! preserveJsDocsEnabled ( ix ) ? null : [
206+ const JSDOCS = ! hasJsDoc ? null : [
197207 '\n/**' ,
198- ` * ${ escapeJsDoc ( description ) } ` ,
208+ $description ,
209+ $default ,
210+ $title ,
211+ $metadata ,
199212 ' */' ,
200213 ] . filter ( ( _ ) => _ !== null )
201214 return [
202215 JSDOCS === null ? null : JSDOCS . join ( '\n' ) ,
203- READONLY + parseKey ( k ) + ( OPT . includes ( k ) ? '?: ' : ': ' ) + v ,
216+ READONLY + parseKey ( k ) + ( OPT . includes ( k ) ? '?: ' : ': ' ) + value ,
204217 ] . filter ( ( _ ) => _ !== null ) . join ( '\n' )
205218 }
206219 )
@@ -244,17 +257,30 @@ const fold = F.fold<string>((x, ix, input) => {
244257 const READONLY_OPEN = isReadonly ( input ) ? 'Readonly<' : ''
245258 const READONLY_CLOSE = isReadonly ( input ) ? '>' : ''
246259 const xs = Object . entries ( x . entries ) . map (
247- ( [ k , v ] ) => {
248- const description = getDescription ( input . entries [ k ] )
260+ ( [ k , value ] ) => {
261+ const originalValue = input . entries [ k ]
262+ const description = v . getDescription ( originalValue )
263+ const title = v . getTitle ( originalValue )
264+ const default_ = v . getDefault ( originalValue )
265+ const metadata = v . getMetadata ( originalValue )
266+ const $description = description === undefined ? null : ` * @description ${ escapeJsDoc ( description ) } `
267+ const $title = title === undefined ? null : ` * @title ${ escapeJsDoc ( title ) } `
268+ const $default = default_ === undefined ? null : ` * @default ${ escapeJsDoc ( JSON . stringify ( default_ , null , 2 ) . split ( '\n' ) . map ( ( line ) => ` * ${ line } ` ) . join ( '\n' ) ) } `
269+ const $metadata = Object . keys ( metadata ) . length === 0 ? null : ` * @metadata \n${ JSON . stringify ( metadata , null , 2 ) . split ( '\n' ) . map ( ( line ) => ` * ${ line } ` ) . join ( '\n' ) } `
270+ const hasJsDoc = preserveJsDocsEnabled ( ix ) && ( $default !== null || $description !== null || $title !== null || $metadata !== null )
271+
249272 const READONLY = isReadonly ( input . entries [ k ] ) ? 'readonly ' : ''
250- const JSDOCS = description == null || ! preserveJsDocsEnabled ( ix ) ? null : [
273+ const JSDOCS = ! hasJsDoc ? null : [
251274 '\n/**' ,
252- ` * ${ escapeJsDoc ( description ) } ` ,
275+ $description ,
276+ $default ,
277+ $title ,
278+ $metadata ,
253279 ' */' ,
254280 ] . filter ( ( _ ) => _ !== null )
255281 return [
256282 JSDOCS === null ? null : JSDOCS . join ( '\n' ) ,
257- READONLY + parseKey ( k ) + ( OPT . includes ( k ) ? '?: ' : ': ' ) + v ,
283+ READONLY + parseKey ( k ) + ( OPT . includes ( k ) ? '?: ' : ': ' ) + value ,
258284 ] . filter ( ( _ ) => _ !== null ) . join ( '\n' )
259285 }
260286 )
0 commit comments