Closed bitomic closed 1 year ago
@HRKings can you review?
@Naramsim, sure thing. I will review it later today
Dropping a comment to make sure it isn't forgotten and the issue goes stale.
Hey @bitomic sorry for the delay, got a bit busy. So, this is a manual fix, but this files are generated automagically, this means that in a future update we would have apply the changes again. The best way would be to modify the generator, want to give it a try ?
I can take a look, but no idea how do you generate the code then. :o Please let me know so I can give it a try! ^^
You can take a look at the generator folder to see how it's make. I can see that you didn't make a overloard for the callbacks too, I think that this will be important as well
I have made some changes to the generator to accomodate everything as I had to update the code to the latest version of the API, mind if I close this PR @bitomic ?
Absolutely no problem, but I am somewhat lost haha. Let me know if I have to do something.
edit: didn't notice there were two comments, only read the lastone.
Currently, using most methods like:
will make
berry
be of typePokeAPITypes.Berry | PokeAPITypes.Berry[]
, so you must guard it with something like:Typescript allows to overload the declaration of a method so, depending on the parameters, it can infer the return type. This PR makes it so passing
number | string
allows typescript to know the result won't be an array, and passingArray<number | string>
will make it know the result will also be an array.This only works with the
async/await
usage of the package. The callback form is untouched.