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

Export CombinePromises input type #2

Open
MonstraG opened this issue May 10, 2021 · 3 comments
Open

Export CombinePromises input type #2

MonstraG opened this issue May 10, 2021 · 3 comments

Comments

@MonstraG
Copy link

I needed to write a wrapper around CombinePromises for nextJs `getServerSideProps', and ended up doing this;

//basically, wrapper to use combinePromises and add {props: } around the object.
type Input = Record<string | number | symbol, Promise<unknown>>; //copied from combine-promises
export const getProps = <Obj extends Input>(requests: Obj) => ({
	props: combinePromises(requests)
});

type Input copied straight from the package, it would be nice to not copy-paste it and being able to import it directly (also, rename it to CombinedPromisesInput or something not to clash with anything)

@slorber
Copy link
Owner

slorber commented May 10, 2021

Is this solving your problem?

type Input = Parameters<typeof combinePromises>[0];

@MonstraG
Copy link
Author

MonstraG commented May 10, 2021

Is this solving your problem?

type Input = Parameters<typeof combinePromises>[0];

It works, but of course this is still a thing I need to write, which I could've exported instead.
But it does work.

Also, it my IDE, webstorm, doesn't give hints correctly, but it's an IDE problem

@slorber
Copy link
Owner

slorber commented May 11, 2021

Exporting the type increase the API surface for little value-added, as this use-case is not the common one.

If we do it we'd rather find a good name for the input/output and commit to not rename those types over time

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