Export CombinePromises input type
MonstraG opened this issue · 3 comments
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)
Is this solving your problem?
type Input = Parameters<typeof combinePromises>[0];
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
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