Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-safe response from multi() #311

Open
smikula opened this issue Jul 4, 2022 · 2 comments
Open

Type-safe response from multi() #311

smikula opened this issue Jul 4, 2022 · 2 comments

Comments

@smikula
Copy link

smikula commented Jul 4, 2022

I'd love to see a type-safe return value from the multi() method on various APIs. I know this is easier said than done — I can't think of a way to do it when passing an array of selection strings — but I there are other ways it could work. Something like:

await torn.user.multi().basic().battlestats().attacks().fetch();

Or:

await torn.user.multi(request => request.basic().battlestats().attacks());

Or with a little ingenuity I think even this could work:

await torn.user.basic().battlestats().attacks();

What do you think? If you're interested, I'd be up for working on a PR.

@jgolla
Copy link
Owner

jgolla commented Jul 5, 2022

@smikula, I would be interested in seeing your ideas. I added the multi calls as more of an afterthought, so they don't fit in as well as the other calls.

@smikula
Copy link
Author

smikula commented Jul 9, 2022

I have a proof of concept idea in this PR: #318

Alternately, you could just define a big return type from multi with all properties there but optional. That's a little annoying to work with as a consumer, but way easier for the library to code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants