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

Typed createSelector function-solution-2 #625

Closed

Conversation

aryaemami59
Copy link
Contributor

This is the second solution for #624. It is not as straightforward but it is done without modifying any of the original types.

export const defaultCreateSelector = createSelectorCreator(defaultMemoize)
export const weakMapCreateSelector = createSelectorCreator(weakMapMemoize)
export const AutotrackCreateSelector = createSelectorCreator(autotrackMemoize)

export type TypedCreateSelectorDefault<State> = <
  Selectors extends readonly Selector<State>[],
  Result
>(
  ...args: Parameters<typeof defaultCreateSelector<Selectors, Result>>
) => ReturnType<typeof defaultCreateSelector<Selectors, Result>>

export type TypedCreateSelectorWeakMap<State> = <
  Selectors extends readonly Selector<State>[],
  Result
>(
  ...args: Parameters<typeof weakMapCreateSelector<Selectors, Result>>
) => ReturnType<typeof weakMapCreateSelector<Selectors, Result>>
// Not sure if this is necessary since the options object for both weakMapMemoize and autotrackMemoize is identical.
export type TypedCreateSelectorAutotrack<State> = <
  Selectors extends readonly Selector<State>[],
  Result
>(
  ...args: Parameters<typeof AutotrackCreateSelector<Selectors, Result>>
) => ReturnType<typeof AutotrackCreateSelector<Selectors, Result>>

I would love to help and contribute as much as I can. So please let me know if there is anything else I can do as I would be more than happy to help.

… not as straightforward but it is done without modifying any of the original types
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9638947:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration

@aryaemami59 aryaemami59 marked this pull request as ready for review September 14, 2023 19:01
@aryaemami59
Copy link
Contributor Author

See #624 (comment)

@aryaemami59 aryaemami59 deleted the TypedCreateSelector-solution-2 branch February 8, 2024 11:35
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

Successfully merging this pull request may close these issues.

1 participant