@@ -63,15 +63,6 @@ function handleTyped(type: Node): Typed {
6363 } ;
6464}
6565
66- function handleAdditionalTypes ( node : Node ) {
67- for ( const child of node . children ) {
68- if ( child . name === "additionalTypes" ) {
69- const additionalTypes = child . values . map ( string ) ;
70- return { additionalTypes } ;
71- }
72- }
73- }
74-
7566function handleTypeParameters ( value : Value | Node ) {
7667 if ( ! value ) {
7768 return { } ;
@@ -271,6 +262,36 @@ function handleProperty(child: Node): Partial<Property> {
271262 } ;
272263}
273264
265+ function handleParam ( node : Node ) {
266+ const name = string ( child . values [ 0 ] ) ;
267+ let additionalTypes : string [ ] | undefined ;
268+
269+ for ( const child of node . children ) {
270+ switch ( child . name ) {
271+ case : "additionalTypes" ) {
272+ if ( additionalTypes ) {
273+ throw new Error ( "Unexpected multiple additionalTypes node" ) ;
274+ }
275+ additionalTypes = child . values . map ( string ) ;
276+ break ;
277+ }
278+ default :
279+ throw new Error ( `Unexpected child "${ c . name } " in param "${ name } "` ) ;
280+ }
281+ }
282+
283+ return {
284+ name,
285+ ...optionalMember ( "type" , "string" , c . properties ?. type ) ,
286+ ...optionalMember (
287+ "overrideType" ,
288+ "string" ,
289+ c . properties ?. overrideType ,
290+ ) ,
291+ additionalTypes,
292+ }
293+ }
294+
274295/**
275296 * Handles a child node of type "method" and adds it to the method object.
276297 * @param child The child node to handle.
@@ -291,16 +312,7 @@ function handleMethod(child: Node): DeepPartial<OverridableMethod> {
291312 break ;
292313
293314 case "param" :
294- params . push ( {
295- name : string ( c . values [ 0 ] ) ,
296- ...optionalMember ( "type" , "string" , c . properties ?. type ) ,
297- ...optionalMember (
298- "overrideType" ,
299- "string" ,
300- c . properties ?. overrideType ,
301- ) ,
302- ...handleAdditionalTypes ( c ) ,
303- } ) ;
315+ params . push ( handleParam ( c ) ) ;
304316 break ;
305317
306318 default :
0 commit comments