When using createStructuredSelector() I discovered it's rather tedious to have to manually provide types for the generics. The function is supposed to help reduce boilerplate, but if you need to provide the types manually, it doesn't help that much after all...
So I created my own type definition that derives the types automatically.
Right now I have a file called types/reselect/index.d.ts in my project that extends the typings from Reselect itself, like this:
namespace Reselect {
export function createStructuredSelector<
S,
T extends Record<string, Reselect.Selector<S>>
>(
selectors: T,
selectorCreator?: typeof Reselect.createSelector
): Reselect.Selector<S, { [K in keyof T]: ReturnType<T[K]> }>;
}
Would the maintainers be interested in upstreaming this? If so, I can help create a PR, or feel free to use this snippet as is.
When using
createStructuredSelector()I discovered it's rather tedious to have to manually provide types for the generics. The function is supposed to help reduce boilerplate, but if you need to provide the types manually, it doesn't help that much after all...So I created my own type definition that derives the types automatically.
Right now I have a file called
types/reselect/index.d.tsin my project that extends the typings from Reselect itself, like this:Would the maintainers be interested in upstreaming this? If so, I can help create a PR, or feel free to use this snippet as is.