@@ -180,8 +180,8 @@ declarationClass.addMethod(methodStructure)
180
180
// setting the parameters typing and binding to the correct interface and endpoint
181
181
for ( const [ methodName , endpoint , jsdocs ] of endpoints ) {
182
182
const inputParam = methodName . match ( / B y N a m e $ / ) ? 'nameOrId' : 'id' ;
183
- const inputParamType = methodName . match ( / B y N a m e $ / ) ? 'string | number | Array<string | number>' : 'number | number[]' ;
184
183
184
+ const inputParamType = methodName . match ( / B y N a m e $ / ) ? 'string | number | Array<string | number>' : 'number | number[]' ;
185
185
methodStructure = {
186
186
name : methodName ,
187
187
isAsync : true ,
@@ -191,7 +191,7 @@ for (const [methodName, endpoint, jsdocs] of endpoints) {
191
191
} ,
192
192
{
193
193
name : 'callback' ,
194
- type : `(result: PokeAPITypes.${ apiMap [ endpoint ] } | PokeAPITypes.${ apiMap [ endpoint ] } [], error?: any) => any` ,
194
+ type : `(( result: PokeAPITypes.${ apiMap [ endpoint ] } , error?: any) => any) & ((result: PokeAPITypes.${ apiMap [ endpoint ] } [], error?: any) => any) ` ,
195
195
hasQuestionToken : true ,
196
196
} ] ,
197
197
returnType : `Promise<PokeAPITypes.${ apiMap [ endpoint ] } | PokeAPITypes.${ apiMap [ endpoint ] } []>` ,
@@ -230,6 +230,29 @@ for (const [methodName, endpoint, jsdocs] of endpoints) {
230
230
handleError(error, callback);
231
231
}` ) ;
232
232
233
+ const singleParamType = methodName . match ( / B y N a m e $ / ) ? 'string | number' : 'number' ;
234
+ const overloadMethodStructure = {
235
+ name : methodName ,
236
+ isAsync : true ,
237
+ parameters : [ {
238
+ name : inputParam ,
239
+ type : singleParamType ,
240
+ } ,
241
+ {
242
+ name : 'callback' ,
243
+ type : `(result: PokeAPITypes.${ apiMap [ endpoint ] } | PokeAPITypes.${ apiMap [ endpoint ] } [], error?: any) => any` ,
244
+ hasQuestionToken : true ,
245
+ } ] ,
246
+ returnType : `Promise<PokeAPITypes.${ apiMap [ endpoint ] } >` ,
247
+ } ;
248
+ generatedMethod . addOverload ( overloadMethodStructure ) ;
249
+
250
+ const multipleParamType = methodName . match ( / B y N a m e $ / ) ? 'Array<string | number>' : 'number[]' ;
251
+ overloadMethodStructure . parameters [ 0 ] . type = multipleParamType ;
252
+ overloadMethodStructure . parameters [ 1 ] . type = `(result: PokeAPITypes.${ apiMap [ endpoint ] } [], error?: any) => any` ;
253
+ overloadMethodStructure . returnType = `Promise<PokeAPITypes.${ apiMap [ endpoint ] } []>` ;
254
+ generatedMethod . addOverload ( overloadMethodStructure ) ;
255
+
233
256
// Add the declaration to the types file
234
257
// Sanitizing the namespace and remove the async keyword
235
258
methodStructure . isAsync = false ;
0 commit comments