File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,30 @@ export function load(app) {
3737 . getReflectionsByKind ( ReflectionKind . Reference )
3838 . forEach ( ref => context . project . removeReflection ( ref ) ) ;
3939
40+ // Destructured parameters are not supported by TypeDoc, so we rename them to
41+ // a more generic name.
42+ context . project
43+ . getReflectionsByKind ( ReflectionKind . Parameter )
44+ . forEach ( param => {
45+ if ( param . name . startsWith ( '__namedParameters' ) ) {
46+ if (
47+ param . type ?. type === 'reflection' &&
48+ param . type . declaration ?. children
49+ ) {
50+ const destructuredKeys = param . type . declaration . children . map (
51+ child => child . name
52+ ) ;
53+ param . name = `{ ${ destructuredKeys . join ( ', ' ) } }` ;
54+ } else if ( param . type ?. type === 'reference' && param . type . name ) {
55+ const interfaceName = param . type . name ;
56+ param . name =
57+ interfaceName [ 0 ] . toLowerCase ( ) + interfaceName . slice ( 1 ) ;
58+ } else {
59+ param . name = 'options' ;
60+ }
61+ }
62+ } ) ;
63+
4064 applyExportEqualsReflections ( context . project ) ;
4165 applySourceMetadata ( context . project ) ;
4266 } ) ;
Original file line number Diff line number Diff line change @@ -55,9 +55,7 @@ export default ctx => {
5555 stability ,
5656 stability && '' ,
5757 model . parameters ?. length &&
58- ctx . partials . parametersList ( model . parameters , {
59- headingLevel : options . headingLevel ,
60- } ) ,
58+ ctx . partials . parametersList ( model . parameters ) ,
6159 ctx . helpers . typedListItem ( {
6260 label : 'Returns' ,
6361 type : model . type ?? 'void' ,
@@ -301,7 +299,22 @@ export default ctx => {
301299
302300 memberTitle : model =>
303301 getMemberTitle ( model , { local : isTypePage ( ctx . page . model ) } ) ,
304- parametersList : ctx . helpers . typedList ,
302+ parametersList ( parameters ) {
303+ const flatList = [ ] ;
304+
305+ parameters . forEach ( param => {
306+ if (
307+ param . type ?. type === 'reflection' &&
308+ param . type . declaration ?. children
309+ ) {
310+ flatList . push ( ...param . type . declaration . children ) ;
311+ } else {
312+ flatList . push ( param ) ;
313+ }
314+ } ) ;
315+
316+ return ctx . helpers . typedList ( flatList ) ;
317+ } ,
305318 typeDeclarationList : ctx . helpers . typedList ,
306319 propertiesTable : ctx . helpers . typedList ,
307320
You can’t perform that action at this time.
0 commit comments