@@ -361,6 +361,50 @@ export const rawTypeToTypeInformation = (
361361 return info ;
362362 } ) ;
363363
364+ // Special case, when the generic type is "Event" then there should be no declared
365+ // innerTypes. Instead we extract the following list as event parameters.
366+ if ( genericTypeString === 'Event' ) {
367+ if ( innerTypes . length ) {
368+ if ( subTypedKeys && ! subTypedKeys . consumed ) {
369+ throw new Error (
370+ 'Found an Event<> declaration with a type declared in the generic, Event<> should not have declared inner types AND a parameter list' ,
371+ ) ;
372+ }
373+
374+ if ( innerTypes . length > 1 ) {
375+ throw new Error (
376+ 'Found an Event<> declaration with multiple types declared in the generic, Event<> should have at most one inner type' ,
377+ ) ;
378+ }
379+
380+ return {
381+ collection,
382+ type : 'Event' ,
383+ eventPropertiesReference : innerTypes [ 0 ] ,
384+ } ;
385+ } else {
386+ if ( ! subTypedKeys || subTypedKeys . consumed ) {
387+ throw new Error (
388+ 'Found an Event<> declaration without a parameter list, either declare as "Event" or provide a parameter list below' ,
389+ ) ;
390+ }
391+
392+ return {
393+ collection,
394+ type : 'Event' ,
395+ eventProperties : consumeTypedKeysList ( subTypedKeys ) . map < PropertyDocumentationBlock > (
396+ typedKey => ( {
397+ name : typedKey . key ,
398+ description : typedKey . description ,
399+ required : typedKey . required ,
400+ additionalTags : typedKey . additionalTags ,
401+ ...typedKey . type ,
402+ } ) ,
403+ ) ,
404+ } ;
405+ }
406+ }
407+
364408 // Special case, when the generic type is "Function" then the first N - 1 innerTypes are
365409 // parameter types and the Nth innerType is the return type
366410 if ( genericTypeString === 'Function' ) {
@@ -384,6 +428,13 @@ export const rawTypeToTypeInformation = (
384428 returns : innerTypes [ innerTypes . length - 1 ] ,
385429 } ;
386430 }
431+
432+ if ( ! innerTypes . length ) {
433+ throw new Error (
434+ `Found a generic declaration without a type declared in the generic, T<> (${ genericTypeString } <>) should have at least one inner type` ,
435+ ) ;
436+ }
437+
387438 return {
388439 collection,
389440 type : genericTypeString ,
0 commit comments