@@ -43,6 +43,21 @@ const ignoreDescriptions = <T extends EventParameterDocumentation>(
43
43
return toReturn ;
44
44
} ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
45
45
46
+ const noDescriptionCache = new WeakMap ( ) ;
47
+ const unsetDescriptions = ( o : any ) : any => {
48
+ if ( noDescriptionCache . has ( o ) ) return noDescriptionCache . get ( o ) ;
49
+ if ( typeof o !== 'object' || ! o ) return o ;
50
+ const val = Array . isArray ( o )
51
+ ? o . map ( item => unsetDescriptions ( item ) )
52
+ : Object . keys ( o ) . reduce ( ( accum : any , key : string ) => {
53
+ if ( key === 'description' ) return accum ;
54
+ accum [ key ] = unsetDescriptions ( o [ key ] ) ;
55
+ return accum ;
56
+ } , { } ) ;
57
+ noDescriptionCache . set ( o , val ) ;
58
+ return val ;
59
+ } ;
60
+
46
61
// Given a parameter create a new interface and return it's name + array modifier
47
62
// IName is the proposed interface name prefix
48
63
// backupIName is a slightly longer IName in case IName is already taken
@@ -53,13 +68,31 @@ const createParamInterface = (
53
68
finalBackupIName = '' ,
54
69
) : string => {
55
70
const maybeArray = ( type : string ) => ( param . collection ? `Array<${ type } >` : type ) ;
71
+ const potentialExistingArgType = polite ( IName ) ;
72
+ const potentialExistingArgName = _ . lowerFirst ( polite ( IName ) ) ;
56
73
let argType = polite ( IName ) + _ . upperFirst ( _ . camelCase ( param . name ) ) ;
57
74
let argName = param . name ;
58
75
// TODO: Note. It is still possible for even backupIName to be already used
59
76
let usingExistingParamInterface = false ;
60
77
_ . forIn ( paramInterfacesToDeclare , ( value , key ) => {
61
- const test = _ . assign ( { } , param , { name : argName , tName : argType } ) ;
62
- if ( _ . isEqual ( test , value ) ) {
78
+ const test = unsetDescriptions (
79
+ _ . assign ( { } , param , {
80
+ name : argName ,
81
+ tName : argType ,
82
+ required : value . required ,
83
+ additionalTags : ( param as any ) . additionalTags || [ ] ,
84
+ } ) ,
85
+ ) ;
86
+ const potentialTest = unsetDescriptions (
87
+ _ . assign ( { } , param , {
88
+ name : potentialExistingArgName ,
89
+ tName : potentialExistingArgType ,
90
+ required : value . required ,
91
+ additionalTags : ( param as any ) . additionalTags || [ ] ,
92
+ } ) ,
93
+ ) ;
94
+ const unsetValue = unsetDescriptions ( value ) ;
95
+ if ( _ . isEqual ( test , unsetValue ) || _ . isEqual ( potentialTest , unsetValue ) ) {
63
96
usingExistingParamInterface = true ;
64
97
debug (
65
98
chalk . cyan (
0 commit comments