@@ -42,6 +42,8 @@ const typify = (type) => {
42
42
43
43
if ( ! type ) return 'any'
44
44
45
+ let innerType
46
+
45
47
if ( typeof type === 'object' ) {
46
48
let newType = type . typeName || type . type || 'any'
47
49
@@ -55,6 +57,10 @@ const typify = (type) => {
55
57
if ( type . collection ) newType += '[]'
56
58
}
57
59
60
+ if ( type . innerType ) {
61
+ innerType = type . innerType
62
+ }
63
+
58
64
type = newType
59
65
}
60
66
@@ -67,9 +73,11 @@ const typify = (type) => {
67
73
case 'integer[]' :
68
74
case 'float[]' :
69
75
return 'number[]'
70
- case 'array' :
76
+ case 'array' : {
77
+ if ( innerType ) return `Array<${ innerType } >`
71
78
debug ( 'Untyped "Array" as return type' . yellow )
72
79
return 'any[]'
80
+ }
73
81
case 'true' :
74
82
case 'false' :
75
83
debug ( '"true" or "false" provided as return value, inferring "Boolean" type' . info )
@@ -94,6 +102,10 @@ const typify = (type) => {
94
102
case 'buffer[]' :
95
103
return 'Buffer[]'
96
104
case 'promise' :
105
+ if ( innerType ) {
106
+ return `Promise<${ innerType } >`
107
+ }
108
+ debug ( 'Promise with missing inner type, defaulting to any' )
97
109
return 'Promise<any>'
98
110
case 'url' :
99
111
return 'string'
@@ -175,13 +187,13 @@ const genMethodString = (paramInterfaces, module, moduleMethod, parameters, retu
175
187
if ( Array . isArray ( param . type ) ) {
176
188
param . type = param . type . map ( ( paramType ) => {
177
189
if ( paramType . typeName === 'Function' && param . parameters ) {
178
- return Object . assign ( { } , paramType , { typeName : genMethodString ( paramInterfaces , module , moduleMethod , param . parameters , param . returns ) } )
190
+ return Object . assign ( { } , paramType , { typeName : genMethodString ( paramInterfaces , module , moduleMethod , param . parameters , param . returns || paramType . innerType ) } )
179
191
}
180
192
return paramType
181
193
} )
182
194
}
183
195
if ( param . type === 'Function' && param . parameters ) {
184
- paramType = genMethodString ( paramInterfaces , module , moduleMethod , param . parameters , param . returns )
196
+ paramType = genMethodString ( paramInterfaces , module , moduleMethod , param . parameters , param . returns || param . innerType )
185
197
}
186
198
187
199
const name = paramify ( param . name )
0 commit comments