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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Add typing to the pre-processors methods #3595

Merged
merged 7 commits into from Jan 17, 2022

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Jan 11, 2022

Extracted from #3593

As it do not impact the users at all, I will automerge 7 days after the review request.
I think other PRs are more worth spending time reviewing 馃憤

@flaviendelangle flaviendelangle added the core Infrastructure work going on behind the scenes label Jan 11, 2022
@flaviendelangle flaviendelangle self-assigned this Jan 11, 2022
@flaviendelangle flaviendelangle marked this pull request as ready for review January 11, 2022 16:07
type GridPreProcessorsApplierArg<
P extends GridPreProcessingGroup,
T extends { value: any },
> = T extends { context: any } ? [P, T['value'], T['context']] : [P, T['value']];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In https://github.com/mui-org/material-ui-x/pull/3595/files#diff-b1ecb3ac2bbd884ca95d8879603f25ff6f844a259f0ceb6207fb06682cc933f6R37 you changed to accept several params. How do you plan to type if we add a pre-processor that has more than 3 arguments in the apiRef.current.unstable_applyPreProcessors call.

const canBeReorderedProcessed = apiRef.current.unstable_applyPreProcessors(
  GridPreProcessingGroup.canBeReordered,
  canBeReordered,
  { targetIndex: targetColVisibleIndex },
  hasMovedLeft,
  hasMovedRight
);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a hack to make TypeScript accept both 1 "params" and 0 "params" without doing something like [value, params] = args as any.

But if it's not clear, maybe the as any it better.

@mui-bot
Copy link

mui-bot commented Jan 17, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean
Filter 100k rows ms 169.6 284.1 203.7 224.78 49.359
Sort 100k rows ms 278.9 814.8 650 587.24 213.168
Select 100k rows ms 203.5 399.9 226.9 256.1 73.101
Deselect 100k rows ms 100.8 303.6 153.4 178.72 74.218

Generated by 馃毇 dangerJS against afd2fee

@flaviendelangle flaviendelangle merged commit c0dd227 into mui:master Jan 17, 2022
@flaviendelangle flaviendelangle deleted the type-pre-processors branch January 17, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants